DB Connect MCP logo

DB Connect MCP

Read-only MCP access to PostgreSQL, MySQL, MariaDB, and ClickHouse for database exploration and SQL analysis.

Install DB Connect 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-connect-mcp": {
      "command": "uvx",
      "args": [
        "db-connect-mcp"
      ],
      "env": {
        "DATABASE_URL": "YOUR_VALUE_HERE",
        "ENABLE_PG_STAT_STATEMENTS": "YOUR_VALUE_HERE",
        "DB_HYPOPG_ENABLED": "YOUR_VALUE_HERE",
        "MCP_ALLOWED_HOSTS": "YOUR_VALUE_HERE",
        "MCP_ALLOWED_ORIGINS": "YOUR_VALUE_HERE"
      }
    }
  }
}

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

Values are written into the snippet above so you can paste it as is. They never leave your browser.

Install not yet sandbox-tested— we haven't run this command through our automated sandbox yet. Not a red flag; we're working through the catalog.

Overview

DB Connect MCP provides read-only database exploration and analysis for PostgreSQL, MySQL/MariaDB, and ClickHouse. It connects through a database URL, validates SQL to allow SELECT and WITH queries, applies result limits, and can reach remote databases through managed SSH tunnels. Use it when an AI assistant needs schema context, table samples, column statistics, safe queries, or query-plan inspection. Claude Desktop can launch it over stdio, while an optional Streamable HTTP mode supports remote deployments.

Use cases

  • Explore schemas and table relationships
  • Profile columns and sample records
  • Run bounded read-only SQL analysis
  • Inspect query plans before tuning
  • Connect to firewalled databases through SSH

Key features

  • PostgreSQL, MySQL/MariaDB, and ClickHouse support
  • Read-only SQL validation and result limits
  • Schema, table, column, and relationship exploration
  • Column statistics and data sampling
  • SSH tunnel management
  • Optional query-plan and hypothetical-index analysis

Tools4

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

Self-reported~32 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.

13/13 checks healthy over the last 76d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 11d ago via OSV.dev · db-connect-mcp (PyPI)

Adoption & maintenance

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

GitHub stars7Stargazers on the source repository.
Last commit2d agoMost recent push to the default branch.
Tools exposed4Callable tools this server registers over MCP.
Directory activity3 viewsConfig copies, upvotes, and views on AllMCPs.

How DB Connect MCP works

What DB Connect MCP does

DB Connect MCP gives MCP-compatible AI clients read-only access to PostgreSQL, MySQL/MariaDB, and ClickHouse databases. It is intended for exploratory data analysis: understanding schemas, inspecting tables, profiling columns, sampling records, searching database objects, and running bounded SQL queries.

The server can expose schema and table metadata, including table size, row counts, comments, columns, indexes, constraints, and foreign-key relationships. Database comments are surfaced during table descriptions, so maintaining useful comments on tables and columns can improve the context available to an AI assistant.

How it works

Install the Python package and start the module as an MCP process. The server reads a DATABASE_URL, detects the database dialect, adds an asynchronous driver when appropriate, and applies database-specific read-only connection settings. PostgreSQL, MySQL/MariaDB, and ClickHouse URL variations are normalized, including supported JDBC prefixes.

SQL execution is restricted to SELECT and WITH statements. Read-only protections operate at multiple levels, and automatic limits help control result sizes. The server can also inspect estimated query plans and, where supported, opt into EXPLAIN ANALYZE.

Remote databases can be reached through an SSH tunnel. Tunnel management includes startup, health checks, restart handling, cleanup, and password- or private-key-based authentication. The same approach supports all three database families.

Setup and configuration

DB Connect MCP requires Python 3.10 or newer and an accessible PostgreSQL 9.6+, MySQL/MariaDB 5.7+/10.2+, or ClickHouse database. Install it with:

Terminal
pip install db-connect-mcp

For a local stdio setup, launch python -m db_connect_mcp and provide DATABASE_URL in the MCP client's environment. Claude Desktop configurations can use this module command directly. An optional Streamable HTTP mode serves the MCP endpoint at /mcp; HTTP deployments should configure forwarded host and origin handling with MCP_ALLOWED_HOSTS and MCP_ALLOWED_ORIGINS when required.

Set ENABLE_PG_STAT_STATEMENTS=true to advertise the optional PostgreSQL get_top_queries capability. It reads bounded cumulative statistics for the current user and database when the administrator has installed and preloaded pg_stat_statements.

Tools and capabilities

  • Explore schemas, tables, views, columns, indexes, relationships, and table metadata.
  • Describe columns, constraints, indexes, and comments.
  • Profile columns with counts, null totals, uniqueness, numeric statistics, quartiles, and value frequencies.
  • Sample table data with configurable limits.
  • Search database objects with SQL-like patterns.
  • Run validated, read-only SQL and inspect query plans.
  • Compare hypothetical PostgreSQL indexes when HypoPG is installed, DB_HYPOPG_ENABLED=true is set, and each call explicitly opts in. This produces planner estimates rather than measured speed improvements.
  • Use inherited MCP SDK OpenTelemetry instrumentation when the launching process configures an SDK and exporter.

Limitations and notes

Write operations are intentionally unavailable. Hypothetical-index comparison is limited to PostgreSQL, requires administrator-installed HypoPG, and accepts a constrained single-SELECT input with one table and one to four columns. The optional top-query report depends on administrator configuration and may expose sensitive query text if explicitly requested.

OpenTelemetry is inactive until configured by the launching process. Database identifiers and error details may be sensitive in exported telemetry, so sampling and redaction should be reviewed before production use. Read-only access still depends on the database permissions assigned to the connection and, for SSH access, valid tunnel credentials.

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 Connect MCP

DB Connect MCP is an MCP server that connects AI clients to PostgreSQL, MySQL/MariaDB, and ClickHouse for read-only database exploration. Its main tools cover schema and table discovery, column profiling, data sampling, object search, validated SELECT or WITH queries, and query-plan inspection, with optional SSH tunneling for remote databases.

Install it with `pip install db-connect-mcp`, then launch `python -m db_connect_mcp` with a `DATABASE_URL` environment variable. Python 3.10 or newer is required, along with a supported PostgreSQL, MySQL/MariaDB, or ClickHouse database.

Add `python -m db_connect_mcp` as the server command in Claude Desktop's `claude_desktop_config.json`, and set `DATABASE_URL` in the configuration's `env` section. Restart Claude Desktop after saving the configuration.

No. DB Connect MCP is read-only: SQL validation permits only SELECT and WITH statements, and connections use multiple read-only safeguards. Automatic limits also help prevent oversized query results.

Use its SSH tunnel configuration to reach a database behind a firewall. The server manages tunnel startup, health checks, recovery, and cleanup, and supports password or private-key authentication for PostgreSQL, MySQL/MariaDB, and ClickHouse.

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 Connect MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/db-connect-mcp?style=directory)](https://allmcps.com/mcp/db-connect-mcp)
HTML Embed
<a href="https://allmcps.com/mcp/db-connect-mcp"><img src="https://allmcps.com/api/badge/db-connect-mcp?style=directory" alt="DB Connect MCP on AllMCPs" /></a>