mcp-database-universal
MCP Database Server
A reasoning interface for databases for MCP-capable AI agents — not a thin SQL wrapper.
mcp-database-universal 为 AI 代理提供了一套 7 个推理工具,用于安全地探索和查询数据库、理解其模式和数据形态、运行自然语言问题以及可视化关系——所有这些都无需暴露原始连接内部细节。
功能特性
7 个推理工具,专为 AI 代理设计:测试连接、列出表、检查表、运行参数化 SQL、用自然语言提问、分析数据以及渲染 ER 图。
多引擎支持:内置 SQLite,以及可选的 PostgreSQL、MySQL 和 MSSQL。
安全优先:默认只读、参数化查询、语句验证、行数/超时/输出限制。
对 LLM 友好的输出:类型转换、
NULL处理、结果以带上下文的 Markdown 表格呈现。模式自省:自动发现表、列、索引、外键和关系。
自然语言查询:将纯文本问题转换为 SQL 并返回结果。
Related MCP server: Universal Database MCP Server
支持的引擎
引擎 | 要求 | 安装额外依赖 |
SQLite | 内置 | — |
PostgreSQL | psycopg |
|
MySQL | PyMySQL |
|
MSSQL | pyodbc + ODBC 驱动 |
|
全部 | — |
|
安装
pip install mcp-database-universal
# With optional engines:
pip install "mcp-database-universal[postgres]"
pip install "mcp-database-universal[mysql]"
pip install "mcp-database-universal[mssql]"
# or everything:
pip install "mcp-database-universal[all]"快速开始
通过 STDIO(MCP 客户端的默认传输方式)运行服务器:
DATABASE_URL=sqlite:///app.db python -m mcp_database_universal连接 URL:
sqlite:///path/to/db.db SQLite (file)
sqlite:///:memory: SQLite (in-memory)
postgresql://user:pass@host:5432/db PostgreSQL
mysql://user:pass@host:3306/db MySQL
mssql://user:pass@host:1433/db MSSQL (uses ODBC Driver 18)Docker
docker build -t mcp-db .
# Mount a SQLite database read-only:
docker run --rm -i \
-v /host/path/app.db:/data/app.db:ro \
-e DATABASE_URL=sqlite:////data/app.db \
mcp-db
# Or in-memory:
docker run --rm -i -e DATABASE_URL=sqlite:///:memory: mcp-db配置
所有配置均通过环境变量完成。
变量 | 默认值 | 描述 |
| (必填) | 数据库连接 URL。 |
|
| 强制只读模式(即使 |
|
| 当 |
|
| 每次查询返回的最大行数。 |
|
| 查询超时时间(秒)。 |
|
| 结果负载大小上限。 |
|
| 表/列统计中显示的示例行数。 |
|
| 分析中 Top-N 值分布条目数。 |
| — | 用于 LLM 支持的 |
| — | 用于 LLM 支持的 |
工具
工具 | 描述 |
| 测试数据库连接;报告引擎、版本、名称、大小、表数量。 |
| 所有表的概览,包含行数、列数、外键关系。 |
| 单个表的完整结构:列、类型、索引、外键、示例数据。 |
| 运行安全、参数化的 SQL 查询并获取 Markdown 结果。 |
| 用纯文本提问;获取生成的 SQL 和结果。 |
| 数据剖析:分布、NULL 率、关系、大小。 |
| 表关系的 Mermaid ER 图。 |
示例:带参数的 query
{
"sql": "SELECT * FROM users WHERE id = :id AND active = :active",
"params": "{\"id\": 42, \"active\": true}"
}参数使用 :name 占位符;在 params 中以 JSON 字符串形式传递值。
示例:natural_query
question: "How many users are there?"
-> SELECT COUNT(*) FROM users
question: "Show me all orders"
-> SELECT * FROM orders LIMIT 100针对小型示例数据库的工作示例位于 examples/ 中,同时包含常见 MCP 客户端的现成配置片段。
MCP 客户端配置
Claude Desktop(claude_desktop_config.json)
{
"mcpServers": {
"database": {
"command": "python",
"args": ["-m", "mcp_database_universal"],
"env": {"DATABASE_URL": "sqlite:///C:/data/app.db"}
}
}
}Cursor / 其他基于 CLI 的客户端
{
"mcpServers": {
"database": {
"command": "uvx",
"args": ["mcp-database-universal"],
"env": {"DATABASE_URL": "sqlite:///C:/data/app.db"}
}
}
}Windows 注意:异步 Postgres 驱动需要 Windows 选择器事件循环。该包在
win32上自动设置此策略,因此无需额外配置。
开发
pip install -e ".[dev]"
pytestPostgreSQL/MySQL 的集成测试使用 Docker Compose,如果服务器不可达则自动跳过:
docker compose -f tests/integration/docker-compose.yml up -d
pytest安全模型
服务器默认只读;
INSERT/UPDATE/DELETE/DROP/ALTER等写语句会被阻止。仅当操作员明确设置
DATABASE_READ_ONLY=false且DATABASE_WRITE_ENABLED=true时才允许写入。查询结果受行数、超时和输出大小限制——可防止失控查询。
许可证
MIT
This server cannot be installed
Maintenance
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
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to query and explore databases including SQLite, PostgreSQL, MySQL, and SQL Server through a secure, read-only workflow. It provides tools for listing connections, inspecting table schemas, and executing SELECT statements directly within VS Code.1
- AlicenseNot gradedqualityAmaintenanceConnect AI agents to SQL databases (SQLite, PostgreSQL, MySQL) with a unified interface for querying data, exploring schemas, inserting rows, and exporting results to CSV. Includes safety features like dangerous query blocking and write guards.13MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to connect to and interact with PostgreSQL, MySQL, SQLite, and MongoDB databases through natural language, supporting schema exploration, query execution, data export, and more.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to interact with PostgreSQL or MySQL databases using natural language. Supports SQL queries, schema discovery, and pre-built aggregations without writing SQL.289MIT
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
Give your agent live data from Twitter, Reddit, the web and GitHub. No API keys, no scraping stack.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/kobramantra-debug/mcp-database-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server