MCP Database Server
MCP 数据库服务器
模型上下文协议 (MCP) 服务器实现,允许大型语言模型 (LLM) 通过自然语言与各种数据库交互。目前支持 MongoDB,并计划支持:
PostgreSQL
蟑螂数据库
Redis
还有更多...
特征
通过自然语言进行数据库操作
目前支持 MongoDB 的功能有:
列出所有收藏
使用过滤和投影查询文档
插入文档
删除文档
聚合管道操作
未来对其他数据库的支持:
PostgreSQL:SQL 查询、表操作
CockroachDB:分布式SQL操作
Redis:键值操作、缓存
Related MCP server: MongoDB
先决条件
Node.js v20.12.2 或更高版本
数据库(目前为 MongoDB,其他数据库即将推出)
Claude 桌面应用程序
安装
克隆存储库:
git clone https://github.com/manpreet2000/mcp-database-server.git
cd mcp-database-server安装依赖项:
npm install构建 TypeScript 代码:
npm run build配置
首先,您需要在 Claude Desktop 配置文件中配置数据库连接:
MacOS
~/Library/Application\ Support/Claude/claude_desktop_config.json视窗
%APPDATA%/Claude/claude_desktop_config.json将以下配置添加到您的claude_desktop_config.json :
{
"mcpServers": {
"database": {
"command": "/path/to/node",
"args": ["/path/to/mcp-database/dist/index.js"],
"env": {
"MONGODB_URI": "your-mongodb-connection-string"
}
}
}
}代替:
/path/to/node替换为您的 Node.js 可执行文件路径,或者直接使用node/path/to/mcp-database为该存储库的绝对路径your-mongodb-connection-string为你的 MongoDB 连接 URL
使用示例
MongoDB 示例
列出数据库中的所有集合:
Can you show me all the collections in my database?从集合中获取特定记录:
Give me 2 records from the chargers collection使用过滤器查询:
Show me all documents in the users collection where status is active插入文档:
Add a new user to the users collection with name John and email john@example.com删除文档:
Remove the user with email john@example.com from the users collection汇总数据:
Show me the total count of users by status in the users collection可用工具
1. 获取集合
列出连接的数据库中的所有集合。
2. 获取集合
使用可选查询参数从集合中检索文档:
collectionName:集合的名称limit:返回的最大文档数(默认值:10,最大值:1000)query:MongoDB 查询对象projection:要包含/排除的字段
3. 插入一个
将单个文档插入集合:
collectionName:集合的名称document:要插入的文档对象
4. 删除一个
从集合中删除单个文档:
collectionName:集合的名称query:查询匹配要删除的文档
5. 聚合
执行聚合管道:
collectionName:集合的名称pipeline:聚合阶段数组options:可选的聚合选项
未来的数据库支持
PostgreSQL
SQL 查询执行
表操作
架构管理
交易支持
蟑螂数据库
分布式 SQL 操作
多区域支持
交易管理
架构操作
Redis
键值操作
缓存机制
发布/订阅操作
数据结构操作
安全
永远不要将数据库连接字符串提交到版本控制
使用环境变量来获取敏感信息
遵循数据库特定的安全最佳实践
贡献
欢迎贡献代码!欢迎提交 Pull 请求。对于重大变更,请先提交一个 issue 来讨论您想要修改的内容。
执照
MIT 许可证 - 详情请参阅许可证
Available Tools
5 toolsaggregateD
| Name | Required | Description | Default |
|---|---|---|---|
| collectionName | Yes | ||
| pipeline | Yes | ||
| options | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
deleteOneD
| Name | Required | Description | Default |
|---|---|---|---|
| collectionName | Yes | ||
| query | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
getCollectionD
| Name | Required | Description | Default |
|---|---|---|---|
| collectionName | Yes | ||
| limit | No | ||
| query | No | ||
| projection | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
getCollectionsD
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
insertOneD
| Name | Required | Description | Default |
|---|---|---|---|
| collectionName | Yes | ||
| document | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Tool has no description.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Tool has no description.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Tool has no description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Tool has no description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Tool has no description.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Tool has no description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
- First observed
aggregate - First observed
deleteOne - First observed
getCollection - First observed
getCollections - First observed
insertOne
TDQS
Scored across 5 tools
The tools have distinct purposes: aggregate, deleteOne, getCollection, getCollections, and insertOne each target different database operations. However, getCollection and getCollections could potentially be confused due to similar naming and lack of descriptions clarifying their exact differences.
Naming is inconsistent with mixed conventions: getCollection and getCollections use camelCase, while deleteOne and insertOne use camelCase with different verb styles, and aggregate stands alone. There is no predictable pattern across all tools.
With 5 tools, the count is reasonable for a database server, but it feels borderline thin for covering full CRUD operations and database management. Key operations like update or query filtering are missing, making the set feel incomplete.
The tool set has significant gaps for a database server: it lacks update operations, query filtering tools, and transaction management. While basic insert, delete, and get operations are present, the surface is incomplete for typical database workflows, likely causing agent failures.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.34 npm175MIT
- AlicenseBqualityAmaintenanceA Model Context Protocol server that provides access to MongoDB databases. This server enables LLMs to inspect collection schemas and execute read-only queries.8222 npm282MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.34 npm2MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.34 npmMIT