# DB Connect MCP [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/yugui923/db-connect-mcp  
**GitHub Stars:** 7  
**Views:** 3  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/db-connect-mcp

## Description
Multi-database MCP server for PostgreSQL, MySQL, and ClickHouse

## Tools
Capabilities this server exposes over MCP:

- **table** — Name of the table
- **column** — Name of the column
- **query** — SQL query (must be SELECT or WITH)
- **pattern** — SQL `LIKE` pattern, such as `%user%`

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "db-connect-mcp": {
    "command": "uvx",
    "args": ["db-connect-mcp"],
    "env": {
      "DATABASE_URL": "",
      "ENABLE_PG_STAT_STATEMENTS": "",
      "DB_HYPOPG_ENABLED": "",
      "MCP_ALLOWED_HOSTS": "",
      "MCP_ALLOWED_ORIGINS": ""
    }
  }
}
```

**Requires environment variables:** `DATABASE_URL`, `ENABLE_PG_STAT_STATEMENTS`, `DB_HYPOPG_ENABLED`, `MCP_ALLOWED_HOSTS`, `MCP_ALLOWED_ORIGINS` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## 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:

```bash
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.

_Full upstream README: https://allmcps.com/mcp/db-connect-mcp/readme_

