Skip to main content
Glama
cjp1016

open-db-mcp

by cjp1016

⚡ open-db-mcp

让 LLM Agent 安全地访问你的数据库

License: MIT Python MCP

简体中文 | 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_minpool_maxmax_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"
      }
    }
  }
}

环境变量说明

变量

默认值

说明

MCP_DATASOURCES_CFG_PATH

config/datasources.json

数据源配置文件路径

MCP_WHITELIST_PATH

config/whitelist.json

白名单配置文件路径

MCP_POOL_MAX

8

每个数据源的连接池上限

MCP_MAX_AFFECTED_ROWS

1000

单次 DML 允许影响的最大行数

MCP_DEFAULT_QUERY_MAX_ROWS

1000

查询默认最大返回行数

MCP_QUERY_TIMEOUT_SEC

30

查询超时(秒)

MCP_AUDIT_LOG_PATH

~/.open-db-mcp/audit.jsonl

审计日志路径

MCP_AUDIT_ENABLED

true

是否启用审计日志

MCP_DM_JDBC_JAR_PATH

libs/DmJdbcDriver18.jar

达梦 JDBC 驱动 jar 路径

所有 MCP_* 变量也可写入 ~/.open-db-mcp/.env 文件,效果相同。

各客户端配置文件位置

客户端

配置文件

Claude Desktop (macOS)

~/Library/Application Support/Claude/claude_desktop_config.json

Claude Desktop (Windows)

%APPDATA%\Claude\claude_desktop_config.json

Cursor

~/.cursor/mcp.json

Trae / 其他

参考对应客户端的 MCP 配置文档,格式相同


Related MCP server: MCP SQL Server

💬 联系 & 赞助


📄 License

MIT © cjp1016

A
license - permissive license
-
quality - not tested
A
maintenance

Maintenance

Maintainers
Response time
0dRelease cycle
2Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    D
    maintenance
    MCP Database Server is a service that provides secure database access for AI assistants and LLM-based tools, supporting SQLite, PostgreSQL, MySQL and MariaDB, and featuring query verification, audit logs and security control functions.
    Last updated
    2
    Apache 2.0
  • F
    license
    A
    quality
    D
    maintenance
    An 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.
    Last updated
    5
  • A
    license
    A
    quality
    A
    maintenance
    Secure MCP server for safe, read-only DB access by AI agents, with SQL guardrails, table allowlists, PII masking, and audit logs
    Last updated
    6
    49
    7
    MIT
  • A
    license
    -
    quality
    D
    maintenance
    A 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.
    Last updated
    3
    MIT

View all related MCP servers

Related MCP Connectors

  • GibsonAI MCP server: manage your databases with natural language

  • MCP server for AI dialogue using various LLM models via AceDataCloud

  • MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cjp1016/open-db-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server