
nam088/mcp-db-server 是从 https://github.com/nam088/mcp-db-server. 导入的 MCP 服务器候选
概览
nam088/mcp-db-server 是从 https://github.com/nam088/mcp-db-server. 导入的 MCP 服务器候选
概述(AI 翻译)
mcp-server-db 是一款通用的生产级模型上下文协议(MCP)服务器,通过一套统一的 113+ 高性能工具套件,赋能 AI 助手与 Postgres、Redis、Elasticsearch、MySQL、MongoDB 和 LDAP 交互。
它以韧性为核心,具备后台懒散连接管理、指数级回溯重试、断路器模式、严格的只读安全执行以及按需动态驱动加载。
为什么是mcp-server-db?
- 多数据库支持:可同时连接Postgres、Redis、Elasticsearch(v7、v8和v9)、MySQL、MongoDB和LDAP目录。
- 按需灯驱动:零臃肿。驱动程序(
pg、ioredis、mongodb、mysql2、@elastic/elasticsearch、ldapts)仅在初始化该数据库引擎连接时动态加载。 - 铁板一文:独立的每连接只读模式,关系数据库在会话层面强制执行,并设有查询结果截断保护以防止LLM上下文溢出。
- 容错架构:服务器无论数据库是否可用,都能立即启动。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
mcp-server-db
mcp-server-db is a universal, production-grade Model Context Protocol (MCP) server that empowers AI assistants to interact with Postgres, Redis, Elasticsearch, MySQL, MongoDB, and LDAP through a unified suite of 113+ high-performance tools.
Built with resilience in mind, it features background lazy connection management, exponential backoff retries, circuit breaker patterns, strict read-only security enforcement, and on-demand dynamic driver loading.
Why mcp-server-db?
- Multi-Database Support: Connect to Postgres, Redis, Elasticsearch (v7, v8 & v9), MySQL, MongoDB, and LDAP directories simultaneously.
- On-Demand Light Drivers: Zero bloat. Drivers (
pg,ioredis,mongodb,mysql2,@elastic/elasticsearch,ldapts) are dynamically loaded only when a connection to that database engine is initialized. - Ironclad Safety: Independent per-connection read-only mode with session-level enforcement for relational databases and query result truncation guards to prevent LLM context overflows.
- Fault-Tolerant Architecture: Server starts instantly regardless of database availability. Dead or unreachable databases fail gracefully without crashing the MCP process or blocking other connections.
- Multi-Connection Routing: Query multiple environments (e.g., production read-only replica + local scratch cache) in parallel within the same session.
Supported Database Engines
| Database Engine | Default Driver | Supported Versions | Key Features & Guardrails |
|---|---|---|---|
| PostgreSQL | pg (optional) |
10+ | Table/Index stats, Health diagnostics, Session-level read_only, Statement timeouts |
| Redis | ioredis (optional) |
5+ | Key/String/Hash/Set/List operations, Automatic 1000-item result truncation cap |
| Elasticsearch | @elastic/elasticsearch / es7-client |
7.x, 8.x, 9.x | Dual-API version facade (v7 legacy & v8/v9 modern), Cluster health, Query DSL |
| MySQL / MariaDB | mysql2 (optional) |
5.7+, 8.0+ | DDL extraction (SHOW CREATE), Processlist management, Indexes & Triggers, Session read-only |
| MongoDB | mongodb (optional) |
4.4+ | Aggregation pipelines, Distinct queries, Index management, Execution plan explain |
| LDAP | ldapts (optional) |
v3 directories (OpenLDAP, AD, etc.) | Search/compare, Add/modify/delete entries, Bulk entry seeding |
Quick Start
1. Installation & Optional Drivers
安装
npx -y mcp-server-db配置
{
"mcpServers": {
"mcp-server-db": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-server-db"],
"env": {
"POSTGRES_URL": "postgresql://user:password@localhost:5432/mydb",
"REDIS_URL": "redis://localhost:6379",
"MONGODB_URL": "mongodb://localhost:27017",
"LDAP_URL": "ldap://localhost:389",
"LDAP_BIND_DN": "cn=admin,dc=example,dc=com",
"LDAP_BIND_PASSWORD": "admin-password"
}
}
}
}