open-db-mcp
Provides database access and management capabilities for MySQL databases, including connection management, query execution, transaction support, and data import/export.
Provides database access and management capabilities for PostgreSQL databases, including connection management, query execution, transaction support, and data import/export.
Provides database access and management capabilities for SQLite databases, including connection management, query execution, transaction support, and data import/export.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@open-db-mcplist all tables in my MySQL database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
⚡ open-db-mcp
让 LLM Agent 安全地访问你的数据库
简体中文 | English
基于 MCP 协议 的多数据源数据库工具,通过 stdio 本地进程与 Claude Desktop / Cursor / Trae 等 AI 客户端即插即用。
支持数据库:MySQL · Oracle · 达梦 · PostgreSQL · Vastbase · openGauss · SQLite
核心能力:多数据源一键切换 · 三层白名单安全护栏 · 影响行数预检 · 事务支持 · 慢 SQL 分析 · CSV/JSON 导入导出 · 跨库 Schema Diff · 插件化驱动扩展
🚀 快速开始
git clone https://github.com/cjp1016/open-db-mcp.git
cd open-db-mcp
uv sync # 安装依赖
uv run open-db-mcp init # 生成 ~/.open-db-mcp/ 配置
uv run open-db-mcp doctor # 健康检查配置数据源
编辑 ~/.open-db-mcp/datasources.json:
{
"MY_MYSQL": {
"driver": "mysql",
"url": "jdbc:mysql://127.0.0.1:3306/test_db",
"user": "root",
"password": "env:DB_PASSWORD"
}
}driver:简写(mysql/oracle/dm/postgres/sqlite)或完整 JDBC 类名password:支持明文或安全引用(env:变量名/keyring:/cmd:)可选参数:
pool_min、pool_max、max_affected_rows
注册到 MCP 客户端
最简配置(使用默认路径 config/datasources.json):
{
"mcpServers": {
"open-db-mcp": {
"command": "open-db-mcp",
"args": ["run"]
}
}
}完整配置(通过 env 注入运行时参数):
{
"mcpServers": {
"open-db-mcp": {
"command": "open-db-mcp",
"args": ["run"],
"env": {
"MCP_DATASOURCES_CFG_PATH": "/path/to/datasources.json",
"MCP_WHITELIST_PATH": "/path/to/whitelist.json",
"MCP_POOL_MAX": "8",
"MCP_MAX_AFFECTED_ROWS": "1000",
"MCP_QUERY_TIMEOUT_SEC": "30",
"MCP_AUDIT_LOG_PATH": "/path/to/audit.jsonl",
"DB_PASSWORD": "your_password"
}
}
}
}环境变量说明:
变量 | 默认值 | 说明 |
|
| 数据源配置文件路径 |
|
| 白名单配置文件路径 |
|
| 每个数据源的连接池上限 |
|
| 单次 DML 允许影响的最大行数 |
|
| 查询默认最大返回行数 |
|
| 查询超时(秒) |
|
| 审计日志路径 |
|
| 是否启用审计日志 |
|
| 达梦 JDBC 驱动 jar 路径 |
所有
MCP_*变量也可写入~/.open-db-mcp/.env文件,效果相同。
各客户端配置文件位置:
客户端 | 配置文件 |
Claude Desktop (macOS) |
|
Claude Desktop (Windows) |
|
Cursor |
|
Trae / 其他 | 参考对应客户端的 MCP 配置文档,格式相同 |
Related MCP server: safedb-mcp
💬 联系 & 赞助
📄 License
MIT © cjp1016
This server cannot be deployed
Maintenance
Related MCP Connectors
Guard AI agents' PostgreSQL/MySQL access via MCP: SQL audit, auth, masking, write approval
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
The Remote MCP server acts as a standardized bridge between LLM applications (like Claude, ChatGPT, and Cursor) and external services, enabling AI agents to access external tools and resources. Its primary capability is providing a centralized search tool to discover other MCP servers and their respective tools. Unlike local implementations, it runs remotely with OAuth authentication and permission controls for security.
Related MCP Servers
- FlicenseAqualityDmaintenanceAn MCP server that connects LLMs to SQL databases for development assistance, enabling query execution, schema exploration, and data manipulation while providing safety controls against destructive operations.5-
- AlicenseAqualityBmaintenanceSecure MCP server for safe, read-only DB access by AI agents, with SQL guardrails, table allowlists, PII masking, and audit logs627 npm8MIT
- AlicenseNot gradedqualityCmaintenanceA secure and efficient MCP server for MySQL database operations, enabling LLMs to execute SQL queries with read-only access by default and optional write permissions.3MIT
- AlicenseAqualityDmaintenanceA multi-database MCP server that enables LLMs to safely interact with MySQL, PostgreSQL, SQLite, and others through a unified tool interface, with permission modes and schema resources.107 npm53MIT