Provides read-only access to MongoDB databases, enabling inspection of collection schemas and execution of aggregation pipelines with safety features like document limits and query timeouts.
MongoDB MCP Server
A Model Context Protocol server that provides read-only access to MongoDB databases. This server enables LLMs to inspect collection schemas and execute aggregation pipelines.
Components
Tools
- aggregate
- Execute MongoDB aggregation pipelines against the connected database
- Input:
collection
(string): The collection to querypipeline
(array): MongoDB aggregation pipeline stagesoptions
(object): Optional aggregation settingsallowDiskUse
(boolean): Allow operations that require disk usagemaxTimeMS
(number): Maximum execution time in millisecondscomment
(string): Comment to identify the operation
- Default limit of 1000 documents if no limit stage is specified
- Default timeout of 30 seconds
- explain
- Get execution plans for aggregation pipelines
- Input:
collection
(string): The collection to analyzepipeline
(array): MongoDB aggregation pipeline stagesverbosity
(string): Detail level of the explanation- Options: "queryPlanner", "executionStats", "allPlansExecution"
- Default: "queryPlanner"
Resources
The server provides schema information for each collection in the database:
- Collection Schemas (
mongodb://<host>/<collection>/schema
)- Inferred JSON schema information for each collection
- Includes field names and data types
- Schema is derived from sampling collection documents
Usage with Claude Desktop
To use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your claude_desktop_config.json
:
Replace mydb
with your database name and adjust the connection string as needed.
Example Usage
Basic Aggregation
Query Explanation
Safety Features
- Automatic limit of 1000 documents if no limit is specified in the pipeline
- Default timeout of 30 seconds for all operations
- Read-only operations only
- Safe schema inference from collection samples
License
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
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.
Provides read-only access to MongoDB databases for LLMs to inspect collection schemas and execute aggregation pipelines.
Related Resources
Related MCP Servers
- -securityFlicense-qualityProvides read-only access to PostgreSQL databases, enabling users to inspect database schemas and execute read-only queries through a Model Context Protocol server.Last updated -3JavaScript
- -securityAlicense-qualityEnables LLMs to interact with MySQL databases by inspecting schemas and executing safe, read-only queries within transactions.Last updated -28JavaScriptMIT License
- -securityFlicense-qualityProvides read-only access to PostgreSQL databases, enabling LLMs to inspect database schemas and execute read-only SQL queries within a secure transaction context.Last updated -19,2481JavaScript
- -securityFlicense-qualityProvides read-only access to PostgreSQL databases, enabling LLMs to inspect database schemas and execute read-only SQL queries.Last updated -19,248JavaScript