适合谁
- 需要在多个 AI 平台和 IDE 中使用自然语言访问数据库的开发者和数据分析师
- 需要连接多种数据库(包括国产数据库)的场景
- 希望提供只读安全访问、避免误操作的环境
Universal DB MCP 是一个功能强大的数据库 MCP 连接器,支持广泛的数据库和平台,提供灵活的架构和多种权限控制,但需要用户注意安全配置和权限管理。
Universal DB MCP 是一个基于 Model Context Protocol (MCP) 的通用数据库连接器,支持 MySQL、PostgreSQL、Oracle、MongoDB 等 17 种数据库,可通过自然语言进行数据查询和分析。它提供 2 种启动模式(stdio/http)和 4 种访问方式(MCP stdio、MCP SSE、MCP Streamable HTTP、REST API),兼容 Claude Desktop、Cursor、Windsurf、VS Code、ChatGPT 等 50+ 平台。默认以只读模式运行,支持多种权限模式、智能缓存、批量查询优化、多 Schema 支持、数据脱敏等功能。
全局安装:npm install -g universal-db-mcp
对于 Claude Desktop,编辑配置文件(macOS: ~/Library/Application Support/Claude/claude_desktop_config.json; Windows: %APPDATA%\Claude\claude_desktop_config.json),添加 mcpServers 配置,然后重启 Claude Desktop。
对于 HTTP 模式:设置环境变量 MODE=http, HTTP_PORT=3000, API_KEYS=your-secret-key,然后运行 npx universal-db-mcp。
{
"mcpServers": {
"my-database": {
"command": "npx",
"args": [
"universal-db-mcp",
"--type", "mysql",
"--host", "localhost",
"--port", "3306",
"--user", "root",
"--password", "your_password",
"--database", "your_database"
]
}
}
}