mongo-mcp
by: QuantGeekDev
A mongo db server for the model context protocol (MCP)
πOverview
Purpose: The MongoDB MCP Server allows Language Learning Models (LLMs) to interact with MongoDB databases using natural language for querying and data management.
Overview: This server acts as a Model Context Protocol (MCP) implementation enabling seamless integration between LLMs and MongoDB, allowing users to conduct operations like querying collections, inspecting schemas, and managing data effortlessly.
Key Features:
-
Collection Schema Inspection: Enables users to explore the structure of database collections easily.
-
Document Querying and Filtering: Offers capabilities to search for documents based on specific criteria using intuitive language commands.
-
Index Management: Allows users to create and manage indexes to optimize data retrieval.
-
Document Operations: Supports various document manipulations such as insertions, updates, and deletions through simple queries.
ποΈ 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)
π Quick Start
To get started, find your MongoDB connection URL and add this configuration to your Claude Desktop config file:
Configuration
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)
Test Sandbox Setup
- 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
Products
- Product details (name, SKU, category)
- Nested specifications
- Price and inventory info
Orders
- Order details with items
- User references
π― Example Prompts
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
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.