
🗄️ MongoDB MCP Server for LLMS

2025.03.05
1
TypeScript数据库中间件自然语言处理数据库
MongoDB MCP Server 是一个模型上下文协议(MCP)服务器,使大型语言模型(LLMs)能够直接与MongoDB数据库交互。通过自然语言查询集合、检查模式和管理数据。
View on GitHub
Overview
基本能力
产品定位
MongoDB MCP Server 是一个用于连接大型语言模型(LLMs)和MongoDB数据库的中间件,提供自然语言驱动的数据库操作能力。
核心功能
- 🔍 集合模式检查
- 📊 文档查询和过滤
- 📈 索引管理
- 📝 文档操作(插入、更新、删除)
适用场景
- 通过自然语言查询MongoDB数据库
- 数据库模式检查和文档管理
- 自动化数据库操作
工具列表
Query Tools
find
: 查询文档,支持过滤和投影listCollections
: 列出可用集合insertOne
: 插入单个文档updateOne
: 更新单个文档deleteOne
: 删除单个文档
Index Tools
createIndex
: 创建新索引dropIndex
: 删除索引indexes
: 列出集合的索引
常见问题解答
- 需要Node.js 18+和npx作为前置依赖
- 可以通过Smithery自动安装
- 提供本地沙箱测试环境
使用教程
使用依赖
- Node.js 18+
- npx
- Docker和Docker Compose(仅用于本地沙箱测试)
- MCP客户端(如Claude桌面应用)
安装教程
通过Smithery安装
npx -y @smithery/cli install mongo-mcp --client claude
手动配置
在Claude Desktop配置文件中添加以下配置:
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"mongo-mcp",
"mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
]
}
}
}
调试方式
本地沙箱设置
- 启动MongoDB:
docker-compose up -d
- 填充测试数据:
npm run seed
测试查询
尝试以下提示语:
"What collections are available in the database?"
"Show me the schema for the users collection"
"Find all users in San Francisco"