open-db-mcp

open-db-mcp

A multi-database MCP server that enables LLM agents to safely access MySQL, Oracle, DM, PostgreSQL, and SQLite databases with security features like whitelist, row count pre-check, and audit logging.

Category
Visit Server

README

<div align="center">

⚡ open-db-mcp

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

License: MIT Python MCP

简体中文 | English

</div>


基于 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 配置文档,格式相同

💬 联系 & 赞助

<div align="center">

<img src="image/wechat.png" alt="微信联系方式" width="220" /> <img src="image/wechat-pay.png" alt="微信打赏二维码" width="220" />

</div>


📄 License

MIT © cjp1016

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured