Mongo-MCP
English | 简体中文
A Machine Chat Protocol (MCP) service for MongoDB operations. This service provides a set of tools that allow Large Language Models (LLMs) to interact with MongoDB databases through basic CRUD operations and administrative tasks.
Requirements
- Python 3.10 or above
- A running MongoDB database service
- It is recommended to use uv to run the program
Features
- MongoDB instance connection management
- List databases and collections
- Document CRUD operations
- Insert documents
- Query documents (supports complex queries and projections)
- Update documents
- Delete documents
- Full support for MongoDB query syntax and projections
- Comprehensive error handling and logging
- Stdin/stdout (stdio) based MCP transport implementation
Usage
Run directly with uvx
uvx run mongo-mcp
The server uses the stdio transport method, making it suitable for integration with MCP clients that support this transport method.
Cursor Example Configuration
If you use Cursor as your development environment, you can add the following configuration to your .cursor/mcp.json file for local debugging:
{
"mcpServers": {
"mongo-mcp": {
"command": "uvx",
"args": [
"mongo-mcp"
],
"env": {
"MONGODB_URI": "mongodb://localhost:27017",
"MONGODB_DEFAULT_DB": "MONGODB_DEFAULT_DB",
"LOG_LEVEL": "INFO"
}
}
}
}
Environment Variables
MONGODB_URI: MongoDB connection string (default: “mongodb://localhost:27017”)MONGODB_DEFAULT_DB: Default database name (optional)LOG_LEVEL: Logging level (default: “INFO”)- Available values: DEBUG, INFO, WARNING, ERROR, CRITICAL
Supported Operations
- List all databases
- List all collections in a specified database
- Insert documents
- Query documents (supports query conditions and field projections)
- Update documents (supports single and bulk updates)
- Delete documents (supports single and bulk deletions)
Development Guide
- Clone the repository
git clone https://github.com/yourusername/mongo-mcp.git
cd mongo-mcp
- Install development dependencies
# Using pip
pip install -e "[dev]"
# Or using uv (recommended for faster installation)
uv pip install -e "[dev]"
- Run tests
pytest
- Code Structure
server.py: MCP server implementationdb.py: Core MongoDB operations implementationconfig.py: Configuration managementtools/: MCP tools implementationtests/: Test cases
Logging
Log files are stored in the logs directory by default. The log level can be controlled through the LOG_LEVEL environment variable.
License
MIT
Contributing
Contributions via Issues and Pull Requests are welcome. Before submitting a PR, please ensure:
- All tests pass
- Appropriate test cases are added
- Documentation is updated
MongoDB Operations Service
Project Details
- 441126098/mongo-mcp
- MIT License
- Last Updated: 6/11/2025
Recomended MCP Servers
A MCP server to allow the LLM in Cursor to access Rust Analyzer, Crate Docs and Cargo Commands.
Linkup is a third-party extension that gives Claude access to real-time web search and premium content sources. It...
A Model Context Protocol server to connect to MongoDB databases and MongoDB Atlas Clusters.
MCP server for accessing Dutch World War II archives through the Oorlogsbronnen API. Provides structured access to historical...
https://pypi.org/project/mcp-prefect/0.1.0/
A Model Context Protocol (MCP) server implementation that provides Elasticsearch and OpenSearch interaction.
MCP server for getting github trending repos & developers
这是一个基于MCP框架的智能客服系统示例项目,用于演示如何构建和部署智能客服应用





