🗄️ MongoDB MCP Server for LLMs
Overview
What is mongo-mcp?
mongo-mcp is a MongoDB server implementation designed for the Model Context Protocol (MCP). This project aims to provide a robust and efficient way to manage and interact with MongoDB databases, facilitating seamless integration with applications that utilize the MCP framework. By leveraging the capabilities of MongoDB, mongo-mcp allows developers to build scalable and high-performance applications.
Features of mongo-mcp
- MCP Compatibility: mongo-mcp is specifically designed to work with the Model Context Protocol, ensuring that it meets the requirements of applications built on this protocol.
- Scalability: Built on MongoDB, mongo-mcp can handle large volumes of data and numerous concurrent connections, making it suitable for enterprise-level applications.
- Ease of Use: The server is designed with user-friendliness in mind, providing a straightforward setup and configuration process.
- Open Source: Being a public repository, mongo-mcp is open for contributions, allowing developers to collaborate and enhance the project.
- Active Community: The project has garnered attention and contributions from a growing community of developers, ensuring continuous improvement and support.
How to Use mongo-mcp
- Installation: Start by cloning the repository from GitHub:
git clone https://github.com/QuantGeekDev/mongo-mcp.git
- Configuration: Navigate to the project directory and configure the server settings according to your requirements. This may include setting up database connections and defining protocols.
- Running the Server: Use the provided scripts or commands to start the mongo-mcp server. Ensure that MongoDB is installed and running on your machine.
- Integration: Connect your applications to the mongo-mcp server using the MCP framework, allowing for efficient data management and retrieval.
Frequently Asked Questions
What is the Model Context Protocol (MCP)?
The Model Context Protocol (MCP) is a framework that defines how applications can interact with data models in a structured manner. It provides guidelines for data manipulation, ensuring consistency and reliability across different applications.
Is mongo-mcp suitable for production use?
Yes, mongo-mcp is designed to be robust and scalable, making it suitable for production environments. However, it is recommended to thoroughly test the server in your specific use case before deploying it in a live setting.
How can I contribute to the mongo-mcp project?
Contributions are welcome! You can contribute by reporting issues, submitting pull requests, or improving documentation. Please refer to the project's GitHub page for contribution guidelines.
Where can I find more information about mongo-mcp?
For more detailed information, documentation, and updates, visit the mongo-mcp GitHub repository.
Details
🗄️ 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 Config
{
"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": {}
}
}
}