Provides a standardized protocol for interacting with MongoDB databases, supporting CRUD operations on documents, collection management, and index operations through async/await patterns.
MongoDB MCP Server
A powerful Model Context Protocol (MCP) server implementation that provides seamless interaction with MongoDB databases over a standardized protocol.
Author
Rastalion
Related MCP server: MongoDB
outline
This MCP server implementation provides a powerful interface to interact with a MongoDB database via the Model Context Protocol. It reliably supports operations on the database, collections, and documents via the async/await pattern and error handling.
characteristic
Full support for MongoDB CRUD operations
Handling secure connections to MongoDB
Async/await pattern for optimal performance
Comprehensive error handling
Docker support for easy deployment
Executing queries with type hints
Support for Server-Sent Events (SSE) for real-time updates
Quick Start
Use as a CLI tool
Run via UVX
Run Python directly
Using Docker
Using UVX
UVX is a tool that allows you to easily manage services in various environments.
For more information, see the UVX Guide .
Environment variables
Before running the server, set the following environment variables:
API endpoint
Check health :
GET /healthMCP API :
GET /mcp- FastMCP endpoint (OpenAPI documentation)SSE Connection :
GET /sse- Server-Sent Events EndpointMessage Processing :
POST /messages- Message Processing Endpoint
IDE Integration
VS Code Settings
Add the following to your VS Code settings.json:
Claude or other AI assistant
Configure your MCP server for Claude or other AI assistants as follows:
Tools available
Tool name | explanation |
| List all available collections in the database |
| Retrieving documents in a collection using MongoDB query syntax |
| Insert a single document into a collection |
| Update a single document in a collection |
| Delete a single document from a collection |
| List all indexes in a collection |
| Create a new index in a collection |
| Delete an existing index from a collection |
Advanced Usage
Add custom tools
Create a new tool in
app/tools/documents/orapp/tools/collection/:
Register the tool in
app/tools/registry.py:
Installing and Deploying CLI Tools
You can make it available globally by registering it as a package on PyPI:
Troubleshooting
If the server does not start : Check help with
mongo-mcp-server --helpMongoDB connection issue : Verify that
--mongodb-urlparameter is correctTool execution error : Check tool implementation and input parameters
Docker issue : Check logs with
docker-compose logs mongo-mcp
Docker configuration
Docker configuration includes:
Python 3.12 base image
Asia/Seoul Time Zone
MongoDB 4.4 instance
Persistent volumes for database storage
Health check for both services
Automated network configuration
License
This project is distributed under the MIT License - see the LICENSE file for details.