A dead-simple, self-hosted MCP server for securely querying databases via AI agents.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
We haven't yet run this listing's install command through our automated sandbox check. This isn't a red flag β we're steadily working through the catalog.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Inspect callable tools, capabilities, and parameters exposed to AI agents by Db Conn MCP.
list_databasesConfigured databases (name, mode, yolo, and `active_port` when a fallback port is in use β **no DSN**).
list_tablesTables and views in a database. Narrow it in the database rather than after the fact: `pattern` keeps only names containing it (fuzzy, case-insensitive) and `limit` caps the number of rows.
get_table_schemaColumns, types, primary/foreign keys for a table. Pass `include_indexes=true` to also get its indexes (`name`, key `columns` in index order β an INCLUDE payload is not listed β `unique`, `method`); omitted by default.
get_database_schemaThe whole database's schema in one deterministic call. `format="json"` (default) returns every table's columns/types/PK/FK; `format="sql"` returns a **self-contained, runnable DDL script** (tables, sequences, PK/FK/UNIQUE/CHECK, indexes, trigger functions, triggers) β no extra tools required. Passβ¦
dump_schema_faithfulByte-faithful** schema dump via the database's own `pg_dump --schema-only` β the most complete/runnable export. Requires the `pg_dump` binary on the server host; if missing, returns `pg_dump_not_found` with install guidance (see the `faithful_schema_export` prompt).
sample_table_rowsFirst N rows of a table (default 10).
A dead-simple, self-hosted Model Context Protocol (MCP) server for querying your databases with AI agents (Claude, Cursor, Windsurf, VS Code, Zed, Codex, and more).
It does one thing well: let an agent safely explore and query a database you point it at β with security delegated to the simplest possible primitives (a static JSON file and your database's own read-only transactions), not custom auth servers or fragile SQL parsing.
v1 ships PostgreSQL only. All database-specific code lives behind a
Dialectseam, so adding MySQL/SQLite later is a single new file.
read database runs every query in a native read-only transaction, and the read tool only accepts a single read-only statement (SELECT/WITH/VALUES/TABLE/SHOW/EXPLAIN) β so an agent can't slip in a write or a SET β¦ READ WRITE to flip the session. For a hard, privilege-level guarantee that holds no matter what, point the DSN at a read-only database role (see Use a read-only role).mode (hard, native) β dry-run first (a commit is refused unless that exact statement was previewed) β yolo (per-database trust) β user_consent (explicit per-operation approval).db-conn-mcp gui opens a local dashboard that does the same, and proves each client can actually launch the server.Requires Python 3.12+.
This installs the db-conn-mcp command.
Not sure how you installed it? Each manager keeps its own registry β ask them:
If none of those know it, your MCP client config is likely launching it via uvx (check the command in the client's config entry β that entry is the source of truth for what actually runs, and which db-conn-mcp / Get-Command db-conn-mcp shows the binary on your PATH).
Then use the matching upgrade command:
Running via uvx (e.g. in an MCP client config)? There's nothing installed to upgrade, but uvx caches resolved versions β use db-conn-mcp@latest as the command to always resolve the newest release, or run uv cache clean db-conn-mcp to force a re-resolve.
After upgrading, restart/reconnect your AI client so it picks up the new version (and any new tools). Verify with db-conn-mcp -v.
You don't have to remember to check. When you run a db-conn-mcp subcommand in a terminal, it prints a single line if a newer release is published β looked up in the background, so it never slows a command down or changes its exit code (offline just means no line). Set DB_CONN_MCP_NO_UPDATE_CHECK=1 to silence it. The server your MCP client launches never checks; db-conn-mcp doctor is the deliberate, authoritative version of the same question.
PyPI's index can lag a release by a minute or two. If your upgrade reports "already at latest" right after a release, retry with
pipx upgrade db-conn-mcp --pip-args="--no-cache-dir"(orpip install --upgrade --no-cache-dir db-conn-mcp).
The wizard asks for:
~/.db-conn-mcp/connections.json) or repo (./connections.json).prod.postgresql://user:pass@host:5432/dbname.read (recommended) or write.1,3 or all).It then writes your config and (optionally) registers the server in your chosen AI clients. Restart/reconnect the client and the tools are available.
Cancelling is safe. Press Ctrl+C at any prompt and nothing is written.
The single source of truth is connections.json, resolved in this order (first match wins):
--config /path/to/connections.json./connections.json (repo-scoped)~/.db-conn-mcp/connections.json (global-scoped)| Field | Required | Meaning |
|---|---|---|
name | yes | Unique identifier the agent uses to pick a database. |
dsn | yes | Connection string. Secret β never shown by any tool. |
mode | yes | read or write. An absolute, native security boundary. |
yolo | no (default false) | If true, skip the per-write consent prompt for this database. The dry-run preview still applies. |
fallback_ports | no | Extra ports to probe, in order, when the primary port refuses or times out. See below. |
fallback_ports (optional) β extra ports probed in order when the
primary port refuses or times out (auth/TLS errors fail immediately and are never
masked). For DSNs behind SSH tunnels that don't always land on the same port.
The winning port is remembered for the server's lifetime and shown as
active_port in list_databases / check_database. Hand-edit the JSON (agents
may too) or answer the wizard prompt. Example:
"fallback_ports": [5433, 15432]Probing is strictly opt-in and bounded: only the ports you list are ever tried (no
scanning), each fallback probe is capped at 5 seconds, and a connection without the key behaves
exactly as it always has. Existing connections.json files keep working untouched β
the server never adds the key to a file that doesn't have it.
connections.jsonis git-ignored by this project's.gitignoreβ never commit real DSNs.
Writes pass through four gates, in order:
mode (hard, native). If the database isn't "mode": "write", the write is rejected β and the connection is opened read-only at the PostgreSQL session level regardless, so it's blocked twice over. Nothing β not yolo, not user_consent, not skip_dry_run β can ever make a read database writable.execute_write_query defaults to dry_run=true. A commit is rejected unless the identical statement was dry-run first. The one escape hatch is skip_dry_run=true, which the agent passes to attest that you explicitly asked to skip the preview β the server can't verify that claim, so it's the same trust model as user_consent (and, like it, useless on a read database). yolo does not waive this stage.yolo (persisted trust). On a write database with yolo: true, the previewed write commits without prompting.user_consent (per-operation). Otherwise the agent must first read the schema, show you the exact SQL, get your "yes", and re-call with user_consent=true.What the dry-run does: it executes the statement in a transaction and always rolls back, returning the rows it would have affected β so only the mode gate applies, nothing commits, and you see the real impact before saying yes. The resulting permission to commit is scoped to that exact statement (same database, SQL, and params), expires after 10 minutes, and is consumed by the commit attempt it authorizes β including one that fails, since a failed commit may still have applied server-side, so a retry has to be previewed afresh. Running the same statement twice means previewing it twice. (A dry-run does still execute server-side until rollback: brief locks, sequence advancement, trigger side effects.)
Reads always run inside a native read-only transaction, and execute_read_query accepts only a single read-only statement (SELECT/WITH/VALUES/TABLE/SHOW/EXPLAIN). That allowlist is what stops an agent from sending SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE to flip the session, or piggy-backing a ; DELETE β¦ onto a read β there's no SQL parsing involved, just a leading-keyword check plus the driver's single-command protocol.
The application-level checks above are defense-in-depth. The hardest boundary is a privilege one: connect with a PostgreSQL role that simply cannot write, so a write fails even if every layer above were bypassed. Create one per database and use its DSN for read connections:
This is the recommended setup for any database that holds data you care about.
Factual signals from GitHub, npm, and our automated checks β not a rating.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/db-conn-mcp)<a href="https://allmcps.com/mcp/db-conn-mcp"><img src="https://allmcps.com/api/badge/db-conn-mcp?style=directory" alt="Db Conn MCP on AllMCPs" /></a>