DB Conn MCP logo

DB Conn MCP

Self-hosted PostgreSQL MCP server for read-only exploration, guarded writes, schema analysis, diagnostics, and large-result queries.

Install DB Conn MCP

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "db-conn-mcp": {
      "command": "uvx",
      "args": [
        "caches"
      ]
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Claude Code command
claude mcp add --transport stdio db-conn-mcp -- uvx caches

Run in your terminal. Add --scope project to share it with your team through .mcp.json.

We couldn’t confirm it starts correctly

We ran the install command but it didn't respond within our test window — this can mean a slow first-time install rather than a real problem.

uvx caches

Process exited before answering initialize.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

db-conn-mcp connects AI agents to configured PostgreSQL databases through a local, self-hosted MCP server. It provides schema discovery, sanitized diagnostics, read-only queries, guarded mutations, query planning, schema exports, database comparison, and cursor-based access to large result sets. Database credentials remain in a local connections.json file and are not returned by tools. Reach for it when an agent needs database access with native read-only transactions, dry-run write protection, and explicit per-database configuration.

Use cases

  • Explore PostgreSQL schemas from an AI coding client
  • Run parameterized read-only queries safely
  • Preview guarded database mutations before committing
  • Compare schemas after a database migration
  • Inspect large query results with cursors

Key features

  • PostgreSQL schema and object discovery
  • Read-only transactions with bind parameters
  • Dry-run and consent-gated writes
  • Runnable and faithful schema exports
  • Cursor-based retrieval for large results
  • Database diagnostics and migration checks

Tools23

What DB Conn MCP lets your agent do. Expand a tool for its parameters.

Self-reported~952 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

16/20 checks healthy over the last 117d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 15d ago via OSV.dev · caches (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars3Stargazers on the source repository.
Last commit23d agoMost recent push to the default branch.
Install checkInconclusiveDidn't respond in our test window — often a slow first install.
Tools exposed23Callable tools this server registers over MCP.
Directory activity5 viewsConfig copies, upvotes, and views on AllMCPs.

How DB Conn MCP works

What db-conn-mcp does

PostgreSQL databases become available to MCP-compatible AI clients through a local server configured with named connections. Agents can inspect databases, tables, columns, keys, indexes, views, functions, triggers, sequences, and other objects; run read-only SQL; preview or commit mutations under server-side safety rules; and investigate operational issues.

The database catalog includes tools for finding columns and values, sampling rows, checking approximate table sizes, comparing schemas, identifying sequences that lag behind column values, and viewing sanitized activity information. Schema exports are available as structured JSON, runnable SQL, or a byte-faithful schema-only export generated with PostgreSQL’s pg_dump.

How it works

Install the Python package and register one or more PostgreSQL DSNs in connections.json. Each connection has a name, DSN, and mode of read or write. Agents refer to the connection by name; database credentials are not exposed through listing or diagnostic tools.

Read-mode connections use PostgreSQL read-only transactions, and read queries accept one validated read-only statement such as SELECT, WITH, VALUES, TABLE, SHOW, or EXPLAIN. Query parameters use PostgreSQL bind markers such as $1 and $2. Write operations are blocked unless the connection is in write mode. By default, a mutation must first run as a rolled-back dry run before an identical statement can commit. Per-operation consent or persisted yolo mode can control the remaining approval step, while skip_dry_run provides an explicitly requested bypass for that stage.

Large read results can be handled with server-side cursors. Opening a cursor returns an identifier, subsequent calls fetch batches, and closing or draining the cursor releases its connection.

Setup and configuration

Python 3.12 or newer is required. Install the package with either:

  • pipx install db-conn-mcp
  • pip install db-conn-mcp

Run db-conn-mcp setup to choose global or repository scope, enter a connection name and PostgreSQL DSN, select read or write mode, optionally configure fallback ports, and inject the server into detected client configurations. The wizard supports Claude, Cursor, Windsurf, VS Code, Zed, Codex, and other detected MCP clients.

Configuration is resolved in this order: an explicit --config path, ./connections.json, then ~/.db-conn-mcp/connections.json. A connection can define fallback_ports for explicitly listed alternate ports. The active port is reported when a fallback succeeds. Configuration files created by the tool use user-only permissions, and DSNs should not be committed to source control.

Tools and capabilities

  • Discover configured databases without exposing DSNs.
  • List tables and views with case-insensitive name filtering and row limits.
  • Inspect table schemas, keys, and optionally indexes.
  • Export complete database schemas as JSON, runnable SQL, or pg_dump output.
  • Execute parameterized read queries and explain their plans, optionally with ANALYZE.
  • Preview and commit writes under mode, dry-run, consent, and yolo controls.
  • Open, fetch, and close cursors for large read results.
  • Find columns or values across tables and retrieve representative rows.
  • Compare databases, check sequences, inspect table statistics, and view sanitized activity.
  • Test connections, change persisted yolo settings, and diagnose configuration or client-launch problems.

Limitations and notes

The shipped database dialect is PostgreSQL. Faithful schema export requires the pg_dump executable on the server host; the tool reports an installation-oriented diagnostic when it cannot find it. Cursor usage is limited to five open cursors, with idle cursors reaped after 15 minutes.

Read-only transactions and SQL validation provide server-side safeguards, but the strongest privilege-level boundary comes from using a PostgreSQL role that is itself read-only. A connection configured with mode: "read" cannot be made writable by yolo, consent, or dry-run options.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about DB Conn MCP

db-conn-mcp is an MCP server that connects AI agents to configured PostgreSQL databases. Its main tools cover schema discovery, read-only and guarded write queries, query plans, schema exports, database comparison, diagnostics, and cursor-based fetching for large result sets. It keeps connection details in local configuration rather than returning DSNs.

Install it with `pipx install db-conn-mcp` or `pip install db-conn-mcp` using Python 3.12 or newer. Then run `db-conn-mcp setup` to create a connection configuration and optionally add the server to detected MCP clients.

Yes, db-conn-mcp can be registered with Cursor through the setup wizard. Choose Cursor among the detected clients during `db-conn-mcp setup`, then restart or reconnect the client so the MCP tools become available.

Write protection starts with the connection mode: read-mode databases reject mutations and use read-only PostgreSQL sessions. Write-mode mutations default to a rolled-back dry run, and committing requires the same statement to have been previewed, with persisted `yolo` or per-operation consent controlling approval.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewDB Conn MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/db-conn-mcp?style=directory)](https://allmcps.com/mcp/db-conn-mcp)
HTML Embed
<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>