MongoDB MCP Server for LLMs

by vivek1612
Verified
MIT License
340
  • Apple

Integrations

  • Enables direct interaction with MongoDB databases, offering tools for collection schema inspection, document querying and filtering, index management, and document operations (insertion, updates, deletion).

🗄️ LLMS 的 MongoDB MCP 服务器

模型上下文协议 (MCP) 服务器,使 LLM 能够直接与 MongoDB 数据库交互。通过自然语言无缝查询集合、检查架构并管理数据。

✨ 特点

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

演示视频

https://github.com/user-attachments/assets/2389bf23-a10d-49f9-bca9-2b39a1ebe654

🚀 快速入门

首先,找到您的 mongodb 连接 URL,并将此配置添加到您的 Claude Desktop 配置文件中:

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

{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "mongo-mcp", "mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin" ] } } }

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 MongoDB MCP 服务器:

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

先决条件

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

测试沙盒设置

如果您没有可连接的 Mongo DB 服务器,并且想要创建示例沙箱,请按照以下步骤操作

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

配置 Claude 桌面

将此配置添加到您的 Claude Desktop 配置文件:

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" ] } } }

测试沙盒数据结构

种子脚本使用示例数据创建三个集合:

用户

  • 个人信息(姓名、电子邮件、年龄)
  • 嵌套地址及坐标
  • 一系列的兴趣
  • 会员日期

产品

  • 产品详情(名称、SKU、类别)
  • 嵌套规范
  • 价格和库存信息
  • 标签和评分

订单

  • 订单详情及商品
  • 用户参考
  • 运输和付款信息
  • 状态跟踪

🎯 示例提示

尝试与 Claude 一起执行这些提示来探索其功能:

基本操作

"What collections are available in the database?" "Show me the schema for the users collection" "Find all users in San Francisco"

高级查询

"Find all electronics products that are in stock and cost less than $1000" "Show me all orders from the user john@example.com" "List the products with ratings above 4.5"

指数管理

"What indexes exist on the users collection?" "Create an index on the products collection for the 'category' field" "List all indexes across all collections"

文档操作

"Insert a new product with name 'Gaming Laptop' in the products collection" "Update the status of order with ID X to 'shipped'" "Find and delete all products that are out of stock"

📝 可用工具

服务器提供了以下用于数据库交互的工具:

查询工具

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

索引工具

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

📜 许可证

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

模型上下文协议服务器使 LLM 能够直接与 MongoDB 数据库交互,从而允许用户通过自然语言查询集合、检查模式和管理数据。

  1. ✨ Features
    1. Demo Video
      1. 🚀 Quick Start
        1. Installing via Smithery
        2. Prerequisites
        3. Test Sandbox Setup
        4. Configure Claude Desktop
        5. Test Sandbox Data Structure
      2. 🎯 Example Prompts
        1. Basic Operations
        2. Advanced Queries
        3. Index Management
        4. Document Operations
      3. 📝 Available Tools
        1. Query Tools
        2. Index Tools
      4. 📜 License
        ID: a5lx0dulpo