MongoDB MCP Server
Overview
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"
Features
- 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.
Tools
This MCP Server provides tools to manage the data stored in MongoDB.
collectiontools to create, drop and list collectionsdocumenttools to insert, update, delete and query documentsindextools to create and manage indexes for efficient queryingaggregationtools to perform complex data processing pipelinesquerytools to find and filter documents with various conditions
Installation
Manual Installation
# 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
Configuration
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 |
Integration with Claude Desktop
You can configure Claude Desktop to use this MCP Server.
- Specify your MongoDB credentials and TLS configuration
- Retrieve your
uvcommand full path (e.g.which uv) - Edit the
claude_desktop_config.jsonconfiguration 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
docker compose up -d
Example Use Cases
- 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.
Contributing
- Fork the repo
- Create a new branch (
feature-branch) - Commit your changes
- Push to your branch and submit a PR!
License
This project is licensed under the MIT License.
Contact
For questions or support, reach out via GitHub Issues.
Recommend MCP Servers 💡
@1Levick3/postgresql-mcp-server
A Model Context Protocol (MCP) server that provides direct PostgreSQL database query execution capabilities with support for parameterized queries and configurable timeouts, designed for the Cursor IDE
@executeautomation/database-server
An MCP Server that provides database access capabilities to Claude, supporting SQLite, SQL Server, PostgreSQL, and MySQL databases.
@yangkyeongmo/mcp-server-openmetadata
A Model Context Protocol (MCP) server implementation for OpenMetadata
arango-server
A TypeScript-based MCP server that provides database interaction capabilities through ArangoDB, enabling core database operations and seamless integration with MCP tools for applications like Claude and VSCode extensions.
mcp-server-vikingdb
a mcp server for vikingdb store and search
Pratye/MEC-Postgres
A Model Context Protocol server providing read and write access to PostgreSQL databases, enabling LLMs to inspect schemas and execute queries.