🗄️ MongoDB MCP Server for LLMS

🗄️ MongoDB MCP Server for LLMS

site icon
2025.03.16 0
数据库管理自然语言查询数据库
MongoDB MCP Server 是一个专为LLMs设计的模型上下文协议服务器,允许LLMs直接与MongoDB数据库进行交互。通过自然语言查询集合、检查模式和管理数据。
View on GitHub

Overview

基本能力

产品定位

MongoDB MCP Server 是一个专为LLMs设计的模型上下文协议服务器,允许LLMs直接与MongoDB数据库进行交互。通过自然语言查询集合、检查模式和管理数据。

核心功能

  • 🔍 集合模式检查
  • 📊 文档查询和过滤
  • 📈 索引管理
  • 📝 文档操作(插入、更新、删除)

适用场景

  • 通过自然语言查询MongoDB数据库
  • 检查和管理数据库模式
  • 执行文档操作(插入、更新、删除)
  • 管理数据库索引

工具列表

Query Tools

  • find: 查询文档,支持过滤和投影
  • listCollections: 列出可用集合
  • insertOne: 插入单个文档
  • updateOne: 更新单个文档
  • deleteOne: 删除单个文档

Index Tools

  • createIndex: 创建新索引
  • dropIndex: 删除索引
  • indexes: 列出集合的索引

常见问题解答

使用教程

使用依赖

  • Node.js 18+
  • npx
  • Docker和Docker Compose(仅用于本地沙盒测试)
  • MCP客户端(例如Claude桌面应用)

安装教程

通过Smithery安装

npx -y @smithery/cli install mongo-mcp --client claude

本地开发模式

  1. 启动MongoDB(使用Docker Compose)
docker-compose up -d
  1. 使用测试数据填充数据库
npm run seed

调试方式

  1. 配置Claude桌面应用 在Claude桌面配置文件中添加以下配置:

MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mongodb": {
      "command": "node",
      "args": [
        "dist/index.js",
        "mongodb://root:example@localhost:27017/test?authSource=admin"
      ]
    }
  }
}
  1. 测试查询 尝试以下提示语来探索功能:
"What collections are available in the database?"
"Show me the schema for the users collection"
"Find all users in San Francisco"

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。