db-mcp
An MCP database gateway that lets you inspect databases, run safe read-only queries, and execute write statements only after an explicit, human-approved preview with a one-time token.
List available database connections (
list_connections).List tables and views in a connection (
list_tables).Describe table columns, keys, foreign keys, and indexes (
describe_table).Execute read-only SQL queries directly (
query), with results capped byDB_MAX_ROWS.Preview mutations and get a short-lived, single-use confirmation token (
preview_mutation).Execute approved mutations only when the exact SQL, connection, and token match (
execute_mutation).Manage credentials through an OS-level vault, including registering connections and importing them from allowed file paths.
Works with PostgreSQL and SQLite out of the box; Oracle, MySQL, SQL Server, and Snowflake are available with extra drivers.
Provides read-only and gated write access to MySQL databases, allowing agents to list tables, describe schemas, and execute read queries, with write operations requiring user approval via tokens.
Provides read-only and gated write access to PostgreSQL databases, allowing agents to list tables, describe schemas, and execute read queries, with write operations requiring user approval via tokens.
Provides read-only and gated write access to Snowflake databases, allowing agents to list tables, describe schemas, and execute read queries, with write operations requiring user approval via tokens.
Provides read-only and gated write access to SQLite databases, allowing agents to list tables, describe schemas, and execute read queries, with write operations requiring user approval via tokens.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@db-mcp show me the schema of the orders table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
An MCP database gateway for LLM agents: read freely, preview writes, approve explicitly.
securedblink gives an LLM a controlled, auditable way to inspect and query databases through the Model Context Protocol. Read-only work runs immediately; every mutating statement must be previewed, bound to a single-use token, and explicitly approved before it touches the database. Credentials live in your OS credential manager — never in chat history, logs, or tool responses.
Table of Contents
Related MCP server: SafeDataBaseMCP
About
securedblink is a local MCP server that sits between your agent and your databases. You declare connections as DB_<NAME> environment variables — the suffix becomes the connection name exposed to the agent. The server classifies every statement: SELECT, EXPLAIN, SHOW/DESCRIBE, and safe WITH run through query; everything else (INSERT, UPDATE, DELETE, DROP, ALTER, TRUNCATE…) is forced through the gated path.
Stack: Python 3.12+, SQLAlchemy 2.0, MCP 1.x, structlog, keyring. PostgreSQL and SQLite work out of the box; other dialects load via optional drivers.
Who it's for: engineers who want to let an agent explore schemas and run reads autonomously, but keep every write visible and reversible — ideal for analytics databases, staging environments, and local development.
How it works
Read lane — free. query executes immediately and returns rows capped by DB_MAX_ROWS (default 500).
Write lane — gated. The flow is deliberately visible:
1. Agent → preview_mutation(connection, sql) → securedblink returns plan + one-time token
2. Agent shows preview and asks for confirmation
3. Human approves in the MCP client
4. Agent → execute_mutation(connection, sql, token) → securedblink validates token
5. securedblink executes, consumes the token, returns the resultThe token binds the exact SQL string and connection name (SHA-256), expires after 5 minutes, and is single-use. A mismatched connection, altered SQL, expired token, or replay is rejected — even if the agent tries.
Vault lane — isolated. Aliases registered with securedblink register or register-from-path are stored in the OS credential manager (macOS Keychain, Linux Secret Service, Windows Credential Manager). The agent sees only the alias; values are redacted from logs and tool output.
Getting started
1. Install the command
Pick one distribution. The binary is the primary entry point for terminals and MCP clients.
macOS / Linux — standalone binary (recommended):
curl -fsSL https://raw.githubusercontent.com/paulushcgcj/securedblink/main/install.sh | bashWindows (PowerShell):
irm https://raw.githubusercontent.com/paulushcgcj/securedblink/main/install.ps1 | iexPyPI / uv — all platforms (use when you need extra drivers):
uv tool install securedblink
# optional drivers
uv tool install 'securedblink[oracle]'
uv tool install 'securedblink[mysql]'
uv tool install 'securedblink[mssql]'Standalone installers bundle PostgreSQL support only. Install via PyPI/
uv toolwhen you need Oracle, MySQL, or MSSQL drivers.
2. Connect a database
Set one or more DB_<NAME> variables. The suffix becomes the MCP connection name.
export DB_LOCAL=sqlite:///./local.db
export DB_ANALYTICS=postgresql://user:password@db.example.com:5432/analytics
export DB_MAX_ROWS=500 # optional; defaults to 500Prefer the credential vault for secrets (see below) rather than exporting passwords in plain text. Never commit real credentials.
3. Run it
securedblinkAn MCP client can now discover local and analytics, list tables, describe schemas, and run reads. Writes will surface a preview and wait for your explicit approval.
Configure an MCP client
The binary must be on the MCP client's PATH. If it isn't, replace securedblink with its absolute path (e.g. /usr/local/bin/securedblink).
Add to ~/.config/opencode/opencode.jsonc or .opencode.json in a project:
{
"mcp": {
"securedblink": {
"type": "local",
"command": ["securedblink"],
"environment": {
"DB_ANALYTICS": "postgresql://user:password@host:5432/analytics",
"DB_LOCAL": "sqlite:///./local.db",
"DB_MAX_ROWS": "500"
}
}
}
}Add to .vscode/mcp.json or ~/.vscode/mcp.json:
{
"servers": {
"securedblink": {
"type": "stdio",
"command": "securedblink",
"env": {
"DB_ANALYTICS": "postgresql://user:password@host:5432/analytics",
"DB_LOCAL": "sqlite:///./local.db",
"DB_MAX_ROWS": "500"
}
}
}
}Keep connection values in your MCP client's environment block or in the vault. Do not commit real credentials to config files.
What it protects
Operation | Behavior |
| Runs immediately through |
| Requires |
Approval token | Binds the exact SQL and connection; 5-minute expiry; single-use |
Credentials | Vault values stay in the system credential manager and never appear in tool responses or logs |
Supported databases
Any SQLAlchemy-compatible dialect works once its driver is installed. PostgreSQL and SQLite need no extra setup.
Database | URL example | Install |
PostgreSQL |
| Included |
SQLite |
| Built in |
Oracle |
|
|
MySQL |
|
|
SQL Server |
|
|
Snowflake |
| Install |
Tools
Tool | Purpose |
| List environment and vault connections |
| List tables and views |
| Show columns, keys, foreign keys, and indexes |
| Execute read-only SQL |
| Preview a write and issue an approval token |
| Execute an approved write |
| Store a connection in the credential vault |
| Import a connection from |
| List vault aliases and metadata |
| Remove a vault alias |
Credential vault
The vault stores credentials in the platform's secure store so the agent can use an alias without ever receiving the username or password.
Register from the terminal:
securedblink register \
--alias analytics \
--jdbc-url "postgresql://host:5432/analytics" \
--username user \
--password password \
--driver org.postgresql.Driver
securedblink listImport from a file — allow-list the directory first:
export SECUREDBLINK_ALLOWED_ROOTS="/path/to/configs"
securedblink register-from-path \
--alias analytics \
--file-path /path/to/configs/analytics.envSupported formats: .env, .properties, and Spring Boot-style .yml/.yaml. Paths outside SECUREDBLINK_ALLOWED_ROOTS are rejected; values are redacted from logs and errors.
Configuration
Variable | Default | Description |
| — | SQLAlchemy URL for a named connection |
|
| Maximum rows returned by |
| — | Colon-separated roots allowed for vault file imports |
Source checkout
Use run.sh for development — it syncs the project, reads .env, detects drivers from DB_* URLs, and installs missing drivers before starting:
DB_LOCAL=sqlite:///./local.db ./run.shThe installed binary does no setup preparation; configure its environment and optional drivers explicitly.
Development
Requirements: Python 3.12+ and uv.
uv sync
uv run pytest -q
uv run ruff check .
uv run mypy --strict securedblinkSee CONTRIBUTING.md for the full workflow and release process.
Security
Please report vulnerabilities according to SECURITY.md. Never place real database credentials in issues, pull requests, or committed config files.
License
Distributed under GPL-3.0.
Available Tools
6 toolsdescribe_tableA
Describe columns, primary key, foreign keys, and indexes for a table.
Inputs: connection_name (required), table_name (required). Returns: result
execute_mutationC
Execute a confirmed write or destructive SQL statement.
Inputs: connection_name (required), sql (required), confirmation_token (required). Returns: result
list_connectionsA
List all database connections available via DB_ environment variables.
Inputs: no named parameters. Returns: result
list_tablesC
List all tables and views in the specified database connection.
Inputs: connection_name (required). Returns: result
preview_mutationB
Preview a write or destructive SQL statement and get a one-time confirmation token.
Inputs: connection_name (required), sql (required). Returns: result
queryB
Execute a read-only SQL query on the specified connection.
Inputs: connection_name (required), sql (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose: describing tables, executing mutations, listing connections, listing tables, previewing mutations, and read-only queries. No overlap or ambiguity.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., describe_table, execute_mutation, list_tables). Even 'query' fits the pattern as a simple verb.
With 6 tools, the set is well-scoped for a database MCP server. Each tool covers a distinct and necessary operation without redundancy.
The set covers basic read/write operations and metadata exploration but lacks DDL tools (create/alter tables) and transaction control. This may be intentional, but it leaves notable gaps for a comprehensive database interface.
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
AI agents propose database changes as reviewable requests — no direct write access.
Preventive human-approval write-gate for AI agents: writes commit only after a human approves.
AI agents need permission before production SQL writes. Pilot $100 · Gateway $299. Lint≠authorize.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to safely work with SQLite databases by enforcing read/write separation, dry-run writes with confirmation, automatic backups, and an audit trail.MIT
- AlicenseAqualityBmaintenanceEnables AI agents to read and write real databases safely by gating every write behind a mandatory propose/confirm preview and securing AWS RDS connections with short-lived IAM tokens.6MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to read local business data and request database mutations, while requiring human approval before updates or deletions are executed. It provides read-only tools, approval workflows, and audit logging to prevent autonomous destructive changes.-
- AlicenseAqualityBmaintenanceEnables AI agents to query PostgreSQL databases securely with read-only defaults, PII masking, rate limiting, and human-approved, expiring mutation tokens.91Apache 2.0