The MongoDB MCP Server is a natural language interface designed for agentic applications to efficiently manage and search data in MongoDB. It integrates seamlessly with MCP (Model Content Protocol) clients, enabling AI-driven workflows to interact with structured and unstructured data in MongoDB. Using this MCP Server, you can ask questions like:
- "Store this document in the collection"
- "Create an index on this field"
- "Find documents matching these criteria"
- "Perform an aggregation pipeline"
- Natural Language Queries: Enables AI agents to query and update MongoDB using natural language.
- Seamless MCP Integration: Works with any MCP client for smooth communication.
- Full MongoDB Support: Handles collections, documents, indexes, and aggregations.
- Search & Filtering: Supports efficient data retrieval and querying in MongoDB.
- Scalable & Lightweight: Designed for high-performance data operations.
This MCP Server provides tools to manage the data stored in MongoDB.
collection
tools to create, drop and list collectionsdocument
tools to insert, update, delete and query documentsindex
tools to create and manage indexes for efficient queryingaggregation
tools to perform complex data processing pipelinesquery
tools to find and filter documents with various conditions
# Clone the repository
git clone [https://github.com/mongodb/mcp-mongodb.git](https://github.com/tkz24589/mcp_mongodb)
cd mcp-mongodb
# Install dependencies using uv
uv venv
source .venv/bin/activate
uv sync
To configure this MongoDB MCP Server, consider the following environment variables:
Name | Description | Default Value |
---|---|---|
MONGODB_HOST |
MongoDB IP or hostname | "127.0.0.1" |
MONGODB_PORT |
MongoDB port | 27017 |
MONGODB_USERNAME |
Database username | None |
MONGODB_PASSWORD |
Database password | None |
MONGODB_AUTH_SOURCE |
Authentication database | "admin" |
MONGODB_SSL |
Enables or disables SSL/TLS | False |
MONGODB_CA_PATH |
CA certificate for verifying server | None |
You can configure Claude Desktop to use this MCP Server.
- Specify your MongoDB credentials and TLS configuration
- Retrieve your
uv
command full path (e.g.which uv
) - Edit the
claude_desktop_config.json
configuration file- on a MacOS, at
~/Library/Application\ Support/Claude/
- on a MacOS, at
{
"mcpServers": {
"mongodb": {
"command": "<full_path_uv_command>",
"args": [
"--directory",
"<your_mcp_server_directory>",
"run",
"src/main.py"
],
"env": {
"MONGODB_HOST": "<your_mongodb_host>",
"MONGODB_PORT": "<your_mongodb_port>",
"MONGODB_USERNAME": "<your_mongodb_username>",
"MONGODB_PASSWORD": "<your_mongodb_password>",
"MONGODB_AUTH_SOURCE": "<your_auth_source>",
"MONGODB_SSL": True|False,
"MONGODB_CA_PATH": "<your_mongodb_ca_path>"
}
}
}
}
You can troubleshoot problems by tailing the log file.
tail -f ~/Library/Logs/Claude/mcp-server-mongodb.log
docker compose up -d
- AI Assistants: Enable LLMs to fetch, store, and process data in MongoDB.
- Chatbots & Virtual Agents: Retrieve document data, manage collections, and personalize responses.
- Data Search & Analytics: Query MongoDB for real-time insights and complex aggregations.
- Document Processing: Manage document collections with flexible schema and indexing.
- Fork the repo
- Create a new branch (
feature-branch
) - Commit your changes
- Push to your branch and submit a PR!
This project is licensed under the MIT License.
For questions or support, reach out via GitHub Issues.