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
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 /health
MCP 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 --help
MongoDB connection issue : Verify that
--mongodb-url
parameter 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.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A powerful Model Context Protocol (MCP) server implementation that provides standardized interaction with MongoDB databases, supporting complete CRUD operations, async patterns, and real-time updates via SSE.
Related MCP Servers
- -securityAlicense-qualityA 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.Last updated -219169MIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that provides access to MongoDB databases. This server enables LLMs to inspect collection schemas and execute read-only queries.Last updated -8256263MIT License
- -securityAlicense-qualityAn MCP server that enables large language models to interact directly with MongoDB databases, allowing them to query collections, inspect schemas, and manage data through natural language.Last updated -219MIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI models to interact with both MySQL and MongoDB databases through a standardized interface, supporting comprehensive database operations including queries, schema management, and CRUD operations.Last updated -146MIT License