🗄️ Mongodb Mcp 服务器用于 Llms
概览
什么是 mongo-mcp?
mongo-mcp 是一个为模型上下文协议(MCP)设计的 MongoDB 服务器实现。该项目旨在提供一种强大且高效的方式来管理和与 MongoDB 数据库交互,促进与使用 MCP 框架的应用程序的无缝集成。通过利用 MongoDB 的能力,mongo-mcp 使开发人员能够构建可扩展和高性能的应用程序。
mongo-mcp 的特点
- MCP 兼容性:mongo-mcp 专门设计用于与模型上下文协议配合使用,确保满足基于该协议构建的应用程序的要求。
- 可扩展性:基于 MongoDB 构建,mongo-mcp 可以处理大量数据和众多并发连接,适合企业级应用程序。
- 易用性:该服务器的设计考虑了用户友好性,提供简单的设置和配置过程。
- 开源:作为一个公共存储库,mongo-mcp 欢迎贡献,允许开发人员协作并增强项目。
- 活跃社区:该项目吸引了越来越多的开发者关注和贡献,确保持续改进和支持。
如何使用 mongo-mcp
- 安装:首先从 GitHub 克隆存储库:
git clone https://github.com/QuantGeekDev/mongo-mcp.git
- 配置:导航到项目目录,根据您的要求配置服务器设置。这可能包括设置数据库连接和定义协议。
- 运行服务器:使用提供的脚本或命令启动 mongo-mcp 服务器。确保您的计算机上已安装并运行 MongoDB。
- 集成:使用 MCP 框架将您的应用程序连接到 mongo-mcp 服务器,实现高效的数据管理和检索。
常见问题解答
什么是模型上下文协议(MCP)?
模型上下文协议(MCP)是一个框架,定义了应用程序如何以结构化的方式与数据模型交互。它提供了数据操作的指导方针,确保不同应用程序之间的一致性和可靠性。
mongo-mcp 适合生产使用吗?
是的,mongo-mcp 设计为强大且可扩展,适合生产环境。然而,建议在将其部署到实时环境之前,针对您的特定用例彻底测试服务器。
我如何为 mongo-mcp 项目做贡献?
欢迎贡献!您可以通过报告问题、提交拉取请求或改善文档来贡献。请参考项目的 GitHub 页面以获取贡献指南。
我在哪里可以找到有关 mongo-mcp 的更多信息?
有关更详细的信息、文档和更新,请访问 mongo-mcp GitHub 存储库。
详情
🗄️ MongoDB MCP Server for LLMS
A 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.
✨ Features
- 🔍 Collection schema inspection
- 📊 Document querying and filtering
- 📈 Index management
- 📝 Document operations (insert, update, delete)
Demo Video
https://github.com/user-attachments/assets/2389bf23-a10d-49f9-bca9-2b39a1ebe654
🚀 Quick Start
To get started, find your mongodb connection url and add this configuration to your Claude Desktop config file:
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"
]
}
}
}
Installing via Smithery
To install MongoDB MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install mongo-mcp --client claude
Prerequisites
- Node.js 18+
- npx
- Docker and Docker Compose (for local sandbox testing only)
- MCP Client (Claude Desktop App for example)
Test Sandbox Setup
If you don't have a mongo db server to connect to and want to create a sample sandbox, follow these steps
- Start MongoDB using Docker Compose:
docker-compose up -d
- Seed the database with test data:
npm run seed
Configure Claude Desktop
Add this configuration to your Claude Desktop config file:
MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
Local Development Mode:
{
"mcpServers": {
"mongodb": {
"command": "node",
"args": [
"dist/index.js",
"mongodb://root:example@localhost:27017/test?authSource=admin"
]
}
}
}
Test Sandbox Data Structure
The seed script creates three collections with sample data:
Users
- Personal info (name, email, age)
- Nested address with coordinates
- Arrays of interests
- Membership dates
Products
- Product details (name, SKU, category)
- Nested specifications
- Price and inventory info
- Tags and ratings
Orders
- Order details with items
- User references
- Shipping and payment info
- Status tracking
🎯 Example Prompts
Try these prompts with Claude to explore the functionality:
Basic Operations
"What collections are available in the database?"
"Show me the schema for the users collection"
"Find all users in San Francisco"
Advanced Queries
"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"
Index Management
"What indexes exist on the users collection?"
"Create an index on the products collection for the 'category' field"
"List all indexes across all collections"
Document Operations
"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"
📝 Available Tools
The server provides these tools for database interaction:
Query Tools
find
: Query documents with filtering and projectionlistCollections
: List available collectionsinsertOne
: Insert a single documentupdateOne
: Update a single documentdeleteOne
: Delete a single document
Index Tools
createIndex
: Create a new indexdropIndex
: Remove an indexindexes
: List indexes for a collection
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
Server配置
{
"mcpServers": {
"mongo-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--quantgeekdev--mongo-mcp--mongo-mcp",
"node dist/index.js {{MONGODB_URI}}"
],
"env": {}
}
}
}