MySQL、MariaDB、PostgreSQL 和 SQLite 数据库 MCP 服务器——内置 PII 遮蔽和写防
概览
一个用于SQL数据库的单二进制MCP服务器。将你的AI助手连接到MySQL/MariaDB、PostgreSQL或SQLite,且不依赖任何运行时。 - — MySQL/MariaDB、PostgreSQL 和 SQLite 从一个二进制文件中获得 - — 模式发现(listDatabases、listTables、listViews、listTriggers、listFunctions、listProcedures、listMaterializedViews)、数据访问(readQuery、writeQuery)、DDL(createDatabase、dropDatabase、dropTable)和 explainQuery。只读模式隐藏写入工具(writeQuery、createDatabase、dropDatabase、dropTable)。有关每个后端的可用性,请参见 MCP 工具。- — ~7 MB,无需 Python/Node/Docker - — stdio(用于 Claude 桌面、光标)和 HTTP(用于远程/多客户端)- — CLI 标志 >环境变量,每个后端的默认值合理 请查看Docker、Cargo及其他方法的安装文档。 在你的项目根节点添加一个.mcp.json文件。MCP客户端读取该文件并自动配置服务器。
概述(AI 翻译)
一个用于SQL数据库的单二进制MCP服务器。将你的AI助手连接到MySQL/MariaDB、PostgreSQL或SQLite,且不依赖任何运行时。
网站文档发行
特色 ✨
- 多数据库 — MySQL/MariaDB、PostgreSQL 和 SQLite 从一个二进制文件中实现
- MCP 工具 — 模式发现(
listDatabases、listTables、listViews、listTriggers、listFunctions、listProcedures、listMaterializedViews)、数据访问(readQuery、writeQuery)、DDL(createDatabase、dropDatabase、dropTable)和explainQuery。只读模式隐藏写入工具(writeQuery、createDatabase、dropDatabase、dropTable)。详见 MCP 工具以了解每个后端的可用性。 - 单一二进制 — ~7 MB,无需 Python/Node/Docker
- 多重传输 — stdio(针对 Claude 桌面、光标)和 HTTP(用于远程/多客户端)
- 两层配置 — CLI 标志环境变量>,每个后端有合理的默认值
- SSH 隧道 — 通过带有嵌入式客户端的 SSH 堡垒访问 MySQL/MariaDB/PostgreSQL:密码或密钥认证、
known_hosts验证,自动重新连接
安装 📦
macOS,Linux,WSL:
Windows PowerShell:
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Database MCP
A single-binary MCP server for SQL databases. Connect your AI assistant to MySQL/MariaDB, PostgreSQL, or SQLite with zero runtime dependencies.
Website · Documentation · Releases

Features ✨
- Multi-database — MySQL/MariaDB, PostgreSQL, and SQLite from one binary
- MCP tools — schema discovery (
listDatabases,listTables,listViews,listTriggers,listFunctions,listProcedures,listMaterializedViews), data access (readQuery,writeQuery), DDL (createDatabase,dropDatabase,dropTable), andexplainQuery. Read-only mode hides the write tools (writeQuery,createDatabase,dropDatabase,dropTable). See MCP Tools for per-backend availability. - Single binary — ~7 MB, no Python/Node/Docker needed
- Multiple transports — stdio (for Claude Desktop, Cursor) and HTTP (for remote/multi-client)
- Layered config —
DBMCP_*environment variables, an env file, and an optional YAML config file with${}interpolation, with sensible defaults per backend - SSH tunnel — reach MySQL/MariaDB/PostgreSQL through an SSH bastion with an embedded client: password or key auth,
known_hostsverification, automatic reconnect
Install 📦
macOS, Linux, WSL:
curl -fsSL https://dbmcp.haymon.ai/install.sh | bash
Windows PowerShell:
irm https://dbmcp.haymon.ai/install.ps1 | iex
Windows CMD:
curl -fsSL https://dbmcp.haymon.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
See the installation docs for Docker, Cargo, and other methods.
Quick Start 🚀
Using .mcp.json (recommended)
Add a .mcp.json file to your project root. MCP clients read this file and configure the server automatically.
Stdio transport — the client starts and manages the server process:
{
"mcpServers": {
"dbmcp": {
"command": "dbmcp",
"env": {
"DBMCP_DB_BACKEND": "mysql",
"DBMCP_DB_HOST": "127.0.0.1",
"DBMCP_DB_PORT": "3306",
"DBMCP_DB_USER": "root",
"DBMCP_DB_PASSWORD": "secret",
"DBMCP_DB_NAME": "mydb"
}
}
}
}
HTTP transport — you start the server yourself, the client connects to it:
# Start the server first
安装
npx @modelcontextprotocol/inspector ./target/release/dbmcp配置
{
"mcpServers": {
"dbmcp": {
"command": "dbmcp",
"env": {
"DBMCP_DB_BACKEND": "mysql",
"DBMCP_DB_HOST": "127.0.0.1",
"DBMCP_DB_PORT": "3306",
"DBMCP_DB_USER": "root",
"DBMCP_DB_PASSWORD": "secret",
"DBMCP_DB_NAME": "mydb"
}
}
}
}