DB Connect MCP — MCP server for PostgreSQL, MySQL and ClickHouse
Gives an agent read-only access to PostgreSQL, MySQL and ClickHouse: schemas, tables, relationships and column profiles.
claude mcp add db-connect-mcp -e DATABASE_URL=<DATABASE_URL> -- uvx db-connect-mcpWhat DB Connect MCP does
The server stays read-only. It accepts SELECT and WITH only, and adds limits so a query cannot drag back a whole table. Every connection is opened with read-only parameters.
Three adapters sit inside: PostgreSQL with metadata and statistics, MySQL and MariaDB, and ClickHouse for analytical workloads. You get column profiling (mean, median, quartiles, value frequency), data sampling, object search and query plans. PostgreSQL also has hypothetical indexes through the HypoPG extension — opt-in, requiring DB_HYPOPG_ENABLED=true and an administrator who installed the extension. Those are planner estimates, not measured speedups.
You need Python 3.10 or higher and a connection string in DATABASE_URL. Databases behind a firewall are reachable over SSH tunnels with a password or a private key. The server does better with databases whose tables and columns carry comments: the agent then understands the data model instead of guessing from names alone.
What it helps with
- explore an unfamiliar database schema without a manual client
- pull the value distribution of a column
- find tables and indexes by name
- check a query plan before running the query
- compare a hypothetical index against the current plan
Example prompts for the agent
- List all schemas and show tables with their sizes
- Describe the
orderstable and its foreign key relationships - Profile the
statuscolumn in theorderstable
How to install DB Connect MCP
Platform CLI
claude mcp add db-connect-mcp -e DATABASE_URL=<DATABASE_URL> -- uvx db-connect-mcpReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from db-connect-mcp <command>
Platform CLI
codex mcp add db-connect-mcp --env DATABASE_URL=<DATABASE_URL> -- uvx db-connect-mcpReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from db-connect-mcp <command>
Config file
{
"mcpServers": {
"db-connect-mcp": {
"command": "uvx",
"args": [
"db-connect-mcp"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from db-connect-mcp <command>
Config file
{
"servers": {
"db-connect-mcp": {
"type": "stdio",
"command": "uvx",
"args": [
"db-connect-mcp"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from db-connect-mcp <command>
Platform CLI
gemini mcp add -e DATABASE_URL=<DATABASE_URL> db-connect-mcp uvx db-connect-mcpReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from db-connect-mcp <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about DB Connect MCP
How do I install DB Connect MCP in Claude Code?
Run claude mcp add db-connect-mcp -e DATABASE_URL=<DATABASE_URL> -- uvx db-connect-mcp with your own connection string.
What does DB Connect MCP do?
It gives an agent read-only access to PostgreSQL, MySQL and ClickHouse: schemas, tables, columns, relationships, data profiling and query plans.
Which databases are supported?
PostgreSQL, MySQL and MariaDB, plus ClickHouse. Each type has its own adapter with safety checks.