MongoDB MCP ServerOfficial
Provides read-only access to MongoDB databases for LLMs to inspect collection schemas and execute aggregation pipelines.
mongodb-developer
README
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
:
"mongodb": {
"command": "npx",
"args": [
"-y" ,
"@pash1986/mcp-server-mongodb"
],
"env" : {
"MONGODB_URI" : "mongodb+srv://<yourcluster>" // 'mongodb://localhost:27017'
}
}
Replace mydb
with your database name and adjust the connection string as needed.
Example Usage
Basic Aggregation
{
"collection": "users",
"pipeline": [
{ "$match": { "age": { "$gt": 21 } } },
{ "$group": {
"_id": "$city",
"avgAge": { "$avg": "$age" },
"count": { "$sum": 1 }
}},
{ "$sort": { "count": -1 } },
{ "$limit": 10 }
],
"options": {
"allowDiskUse": true,
"maxTimeMS": 60000,
"comment": "City-wise user statistics"
}
}
Query Explanation
{
"collection": "users",
"pipeline": [
{ "$match": { "age": { "$gt": 21 } } },
{ "$sort": { "age": 1 } }
],
"verbosity": "executionStats"
}
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.
Recommended Servers
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Supabase MCP Server
A Model Context Protocol (MCP) server that provides programmatic access to the Supabase Management API. This server allows AI models and other clients to manage Supabase projects and organizations through a standardized interface.
@kazuph/mcp-gmail-gas
Model Context Protocol server for Gmail integration. This allows Claude Desktop (or any MCP client) to interact with your Gmail account through Google Apps Script.
MCP DuckDB Knowledge Graph Memory Server
A memory server for Claude that stores and retrieves knowledge graph data in DuckDB, enhancing performance and query capabilities for conversations with persistent user information.
dbt Semantic Layer MCP Server
A server that enables querying the dbt Semantic Layer through natural language conversations with Claude Desktop and other AI assistants, allowing users to discover metrics, create queries, analyze data, and visualize results.
Metabase MCP Server
Enables AI assistants to interact with Metabase databases and dashboards, allowing users to list and execute queries, access data visualizations, and interact with database resources through natural language.

Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Airtable MCP Server
A Model Context Protocol server that provides tools for programmatically managing Airtable bases, tables, fields, and records through Claude Desktop or other MCP clients.
mcp-shodan
MCP server for querying the Shodan API and Shodan CVEDB. This server provides tools for IP lookups, device searches, DNS lookups, vulnerability queries, CPE lookups, and more.
Verodat MCP Server
An MCP server that integrates Verodat's data management capabilities with AI systems like Claude Desktop, enabling users to manage accounts, workspaces, and datasets, as well as perform AI-powered queries on their data.