DB Connect MCP
概览
作者提供的说明(英文原文)
Multi-database MCP server for PostgreSQL, MySQL, and ClickHouse
PopNx MCP 的三大支柱
这三项永远不会合并成一个分数:意见、测量和人气是不同的东西。
- 用户评价i暂无评价评价功能将在后续阶段与账户功能一起开放
- 我们的基础检查i1 项中通过 1 项依据公开信息检查;尚未扫描代码
- 使用情况i非常新↓ 96/周 · ★ –
它能帮你做什么
我们还没有为它写通俗的介绍。下面是我们从注册中心读取到的事实。
- 连接方式: 在你的电脑上运行
- 传输方式: stdio
- 分类: 数据库与数据集
- 你需要填写:DATABASE_URL
安装
选择你使用的 AI 应用,然后复制设置。
安装之前
- 基础检查:1 项中通过 1 项
- 在你的电脑上运行,拥有你的用户账户的权限(文件、网络、应用)。
- 需要你自己填写:
DATABASE_URL
标为机密的值是你账户的钥匙。千万不要分享给别人,也不要粘贴到聊天里。
你需要
- PyPI已安装 Python 的 uv(用于 uvx 命令)
你用的是哪个应用?
在上方选择你的应用。我们会记住它,下次按钮会显示“安装到 …”。
打开 Claude Desktop → Settings → Developer → Edit Config,把下面的内容粘贴到 claude_desktop_config.json
{
"mcpServers": {
"db-connect": {
"command": "uvx",
"args": [
"db-connect-mcp"
],
"env": {
"DATABASE_URL": "your-value"
}
}
}
}在终端中运行这条命令
claude mcp add db-connect --env DATABASE_URL=your-value -- uvx db-connect-mcp运行前请先填写空着的值。
或者自己复制设置
粘贴到项目中的 .cursor/mcp.json,或 ~/.cursor/mcp.json
{
"mcpServers": {
"db-connect": {
"command": "uvx",
"args": [
"db-connect-mcp"
],
"env": {
"DATABASE_URL": "your-value"
}
}
}
}浏览器会先询问是否打开应用,然后应用会显示设置并请你确认。密钥的值会留空,由你自己填写。
或者自己复制设置
粘贴到项目中的 .vscode/mcp.json
{
"servers": {
"db-connect": {
"type": "stdio",
"command": "uvx",
"args": [
"db-connect-mcp"
],
"env": {
"DATABASE_URL": "your-value"
}
}
}
}浏览器会先询问是否打开应用,然后应用会显示设置并请你确认。密钥的值会留空,由你自己填写。
这个服务器在你的电脑上运行,而 ChatGPT 只能连接互联网上的服务器。请选择其他应用。
你的选择通过 Cookie 保存在这台设备上,无需账户。
需要你填写的值
- Database connection URL (e.g., postgresql+asyncpg://user:pass@host:5432/db)
这些设置是根据作者在注册中心的条目生成的。如果 README 的写法不同,请以 README 为准。
它能做什么
它在你的电脑上运行;安装后,工具列表会显示在你的 AI 应用中。
基础检查i
我们检查的是任何人都能看到的信息;我们没有阅读代码。不适用的检查项不计入总数。 · 检查于 2026年11月8日
- ✓ 通过
作者与仓库一致
注册名称已通过 GitHub 账户 yugui923 验证,该账户拥有此仓库
- … 尚未检查
仍在维护
我们还没有从 GitHub 读取这个仓库
- … 尚未检查
有许可证
我们还没有从 GitHub 读取这个仓库
- – 不适用
端点有响应
它在你的电脑上运行,没有互联网端点
- – 不适用
使用 OAuth 登录
在你的电脑上运行,改用本地设置
- … 尚未检查
工具描述中没有隐藏指令
它在你的电脑上运行;我们只能读取互联网端点的工具列表
与“数据库与数据集”中的其他服务器比较i
- 星标数多于此分类中其他 1146 个服务器的 0%
- 发布到注册中心的时间比此分类中其他 1146 个服务器的 4% 更新
- 基础检查结果等于或优于此分类中其他 1146 个服务器的 100%
与注册中心里这个分类中所有活跃的服务器比较。只有当发布者拥有该仓库时,星标数才计入。
常见问题
DB Connect MCP 安全吗?
它在 1 项适用的基础检查中通过了 1 项。我们没有阅读代码。在添加密钥或令牌之前,请先看看这个服务器要求哪些权限,并使用只具备所需权限的密钥。
它需要哪些密钥或代码?
你需要填写:DATABASE_URL
它在我的电脑上运行还是在云端?
它在你的电脑上运行。你的 AI 应用会在需要时启动它,数据不会经过作者的服务器(除非它自己调用在线服务)。
它还在维护吗?
GitHub 仓库最后更新于–,最新版本(0.3.1)于9个月前进入注册中心。
哪些应用可以使用它?
支持 MCP 的应用,例如 Claude Desktop、Claude Code、Cursor 和 VS Code。你的电脑上还需要有 Python (uv)。
有什么可以替代它?
同一分类中有:Supabase, MongoDB MCP Server, Elasticsearch MCP Server
替代选择
同一分类中其他作者的服务器,按星标数排序。
如何看卡片:↓ 每周下载量i★ GitHub 星标i三大支柱:评价 · 检查 · 使用情况i更新 = 最新版本发布到注册中心的时间i
作者的 README
打开 README
按原文从作者的仓库复制。PopNx MCP 没有审查或背书其内容。HTML、图片和脚本已被移除。链接会离开本站。
db-connect-mcp - Multi-Database MCP Server
A read-only MCP (Model Context Protocol) server for exploratory data analysis across multiple database systems. This server provides safe, read-only access to PostgreSQL, MySQL, and ClickHouse databases with comprehensive analysis capabilities.
Demo
Quick Start
- Install:
pip install db-connect-mcp
- Add to Claude Desktop
claude_desktop_config.json:
{
"mcpServers": { "db-connect": { "command": "python", "args": ["-m", "db_connect_mcp"], "env": { "DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb" } } } }
- Restart Claude Desktop and start querying your database!
Note: Using
python -m db_connect_mcpensures the command works even if Python's Scripts directory isn't in your PATH. ExistingmcpServersconfigurations remain valid: stdio is still the default. The optional remote Streamable HTTP mode serves both older initialize-based clients and 2026-07-28 session-free MCP clients at/mcpwithout changing the database or SSH configuration. Existing HTTP deployments must review forwarded Host/Origin values: the upgrade enables transport validation and may requireMCP_ALLOWED_HOSTS/MCP_ALLOWED_ORIGINS.
Features
🗄️ Multi-Database Support
- PostgreSQL - Full support with advanced metadata and statistics
- MySQL - Complete support for MySQL and MariaDB databases
- ClickHouse - Support for analytical workloads and columnar storage
🔍 Database Exploration
- List schemas - View all schemas in the database
- List tables - See all tables with metadata (size, row counts, comments)
- Describe tables - Get detailed column information, indexes, and constraints
- View relationships - Understand foreign key relationships between tables
📊 Data Analysis
- Column profiling - Statistical analysis of column data
- Basic statistics (count, unique values, nulls)
- Numeric statistics (mean, median, std dev, quartiles)
- Value frequency distribution
- Cardinality analysis
- Data sampling - Preview table data with configurable limits
- Custom queries - Execute read-only SQL queries safely
- Object search - Find schemas, tables, views, columns, and indexes without loading the full catalog
- Query plans - Inspect estimated plans or opt into
EXPLAIN ANALYZEwhere supported - Hypothetical indexes (PostgreSQL, opt-in) - Compare HypoPG planner estimates without creating a real index. Requires an administrator-installed HypoPG extension,
DB_HYPOPG_ENABLED=trueon the server, andopt_in=trueon eachcompare_hypothetical_indexcall. Provide a single simple SELECT, schema, table, and 1–4 column names; comments, CTEs, functions, literals, parameters, and multiple statements are rejected. The tool uses one read-only connection andEXPLAINwithoutANALYZE, caps planning/lock waits at 5s/1s, and rolls back session-local changes. The response reportshypothetical_index_usedby matching the HypoPG index name in the resulting plan; an unused candidate may be irrelevant or simply not chosen by the planner. The candidate requires schemaUSAGEand tableSELECTprivileges. These estimates are not measured speedups.
🔒 Safety Features
- Read-only enforcement - All connections are read-only at multiple levels
- Query validation - Only SELECT and WITH queries are allowed
- Automatic limits - Queries are automatically limited to prevent large result sets
- Connection string safety - Automatically adds read-only parameters
- Database-specific safety - Each adapter implements appropriate safety measures
🔭 Observability
db-connect-mcp inherits the MCP SDK's built-in OpenTelemetry server instrumentation. The API is a no-op until the launching process configures an SDK and exporter. Review exporter sampling and redaction before production use, because database identifiers and error details may be sensitive.
💡 Best Practices
Tip: db-connect-mcp works best with databases that have proper comments on tables and columns. When your database includes descriptive comments, the MCP server can provide richer context to AI assistants, leading to better understanding of your data model and more accurate query suggestions.
Adding comments in PostgreSQL:
COMMENT ON TABLE users IS 'Registered user accounts with profile information';
COMMENT ON COLUMN users.email IS 'Primary email address, used for authentication'; COMMENT ON COLUMN users.is_verified IS 'Whether email has been verified via confirmation link';
Adding comments in MySQL:
ALTER TABLE users COMMENT = 'Registered user accounts with profile information';
ALTER TABLE users MODIFY COLUMN email VARCHAR(255) COMMENT 'Primary email address, used for authentication';
The server automatically retrieves and displays these comments when describing tables, helping AI assistants understand the purpose and semantics of your data.
🔐 SSH Tunnel Support
- Secure remote access - Connect to databases behind firewalls via SSH tunnels
- Automatic tunnel management - Tunnel lifecycle handled transparently (start, health check, restart, cleanup)
- Reliable native forwarding - Paramiko
SSHClienttransport with target preflight and stable-port recovery - Flexible authentication - Password or private key based SSH authentication
- Any database type - Works with PostgreSQL, MySQL, and ClickHouse through the same tunnel
See the SSH Tunnel Guide for configuration details.
Installation
Prerequisites
- Python 3.10 or higher
- A database: PostgreSQL (9.6+), MySQL/MariaDB (5.7+/10.2+), or ClickHouse
Install via pip
pip install db-connect-mcp
That's it! The package is now ready to use.
For developers: See Development Guide for setting up a development environment.
Configuration
Create a .env file with your database connection string:
DATABASE_URL=your_database_connection_string_here
The server automatically detects the database type and adds appropriate read-only parameters.
For PostgreSQL, set ENABLE_PG_STAT_STATEMENTS=true to advertise the optional get_top_queries tool. It reads bounded cumulative statistics for the current user/database if pg_stat_statements was installed and preloaded by the database administrator. It does not install extensions. Query text is omitted unless explicitly requested and can contain sensitive information. See the top-query report contract for bounds and statuses.
Connection String Examples
The server now provides more flexible and secure URL handling:
- Automatic driver detection: Async drivers are automatically added if not specified
- JDBC URL support: JDBC prefixes are automatically handled
jdbc:postgresql://...→postgresql+asyncpg://...jdbc:mysql://...→mysql+aiomysql://...- Works with all dialect variations (e.g.,
jdbc:postgres://,jdbc:mariadb://) - Database dialect variations: Common variations are automatically normalized
- PostgreSQL:
postgresql,postgres,pg,psql,pgsql - MySQL/MariaDB:
mysql,mariadb,maria - ClickHouse:
clickhouse,ch,click - Allowlist-based parameter filtering: Only known-safe parameters are preserved
- Database-specific parameters: Each database type has its own set of supported parameters
- Robust parsing: Handles various URL formats gracefully
PostgreSQL:
# Simple URL (driver automatically added)
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
Common variations (all normalized to postgresql+asyncpg)
DATABASE_URL=postgres://user:pass@host:5432/db # Heroku, AWS RDS style DATABASE_URL=pg://user:pass@host:5432/db # Short form DATABASE_URL=psql://user:pass@host:5432/db # CLI style
JDBC URLs (automatically converted)
DATABASE_URL=jdbc:postgresql://user:pass@host:5432/db # From Java apps DATABASE_URL=jdbc:postgres://user:pass@host:5432/db # JDBC with variant
With explicit async driver
DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/db
With supported parameters (see list below)
DATABASE_URL=postgres://user:pass@host:5432/db?application_name=myapp&connect_timeout=10
Supported PostgreSQL Parameters:
application_name- Identifies your app in pg_stat_activity (useful for monitoring)connect_timeout- Connection timeout in secondscommand_timeout- Default timeout for operationsssl/sslmode- SSL connection requirements (automatically converted for asyncpg compatibility)server_settings- Server settings dictionaryoptions- Command-line options to send to server- Performance tuning:
prepared_statement_cache_size,max_cached_statement_lifetime, etc.
MySQL/MariaDB:
# Simple URL (driver automatically added)
DATABASE_URL=mysql://root:password@localhost:3306/mydb
MariaDB URLs (normalized to mysql+aiomysql)
DATABASE_URL=mariadb://user:pass@host:3306/db # MariaDB style DATABASE_URL=maria://user:pass@host:3306/db # Short form
JDBC URLs (automatically converted)
DATABASE_URL=jdbc:mysql://user:pass@host:3306/db # From Java apps DATABASE_URL=jdbc:mariadb://user:pass@host:3306/db # JDBC MariaDB
With explicit async driver
DATABASE_URL=mysql+aiomysql://user:pass@host:3306/db
With charset (critical for proper Unicode support)
DATABASE_URL=mariadb://user:pass@remote.host:3306/db?charset=utf8mb4
Supported MySQL Parameters:
charset- Character encoding (e.g., utf8mb4) - critical for data integrityuse_unicode- Enable Unicode supportconnect_timeout,read_timeout,write_timeout- Various timeoutsautocommit- Transaction autocommit modeinit_command- Initial SQL command to runsql_mode- SQL mode settingstime_zone- Time zone setting
ClickHouse:
# Simple URL (driver automatically added)
DATABASE_URL=clickhouse://default:@localhost:9000/default
Short forms (normalized to clickhouse+asynch)
DATABASE_URL=ch://user:pass@host:9000/db # Short form DATABASE_URL=click://user:pass@host:9000/db # Alternative
JDBC URLs (automatically converted)
DATABASE_URL=jdbc:clickhouse://user:pass@host:9000/db # From Java apps DATABASE_URL=jdbc:ch://user:pass@host:9000/db # JDBC with short form
With explicit async driver
DATABASE_URL=clickhouse+asynch://user:pass@host:9000/db
With performance settings
DATABASE_URL=ch://user:pass@host:9000/db?timeout=60&max_threads=4
Supported ClickHouse Parameters:
database- Default database selectiontimeout,connect_timeout,send_receive_timeout- Various timeoutscompress,compression- Enable compressionmax_block_size,max_threads- Performance tuning
Note:
- SSL parameters (
ssl,sslmode) are automatically converted to the correct format for asyncpg - Certificate file parameters (`sslc
只显示了开头部分;其余内容请在仓库中阅读