MongoDB MCP Server
OfficialProvides 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.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MongoDB MCP Servershow me the schema for the users collection"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 explanationOptions: "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
Related MCP server: mcp-mongo
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.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityCmaintenanceEnables LLMs to interact with MongoDB databases through a complete suite of CRUD operations, administrative tasks, and index management tools. It supports database and collection handling, aggregation pipelines, and comprehensive server monitoring via the Model Context Protocol.Last updated3MIT
- Flicense-qualityDmaintenanceEnables AI agents to query and introspect MongoDB databases through find, aggregate, and schema discovery operations. Supports read-only default mode with optional write capabilities and works with any MCP-compatible client via stdio or HTTP transports.Last updated
- Flicense-qualityCmaintenanceProvides read-only access to legacy MongoDB instances (<4.0) via the Model Context Protocol, enabling AI models to query databases, collections, and run aggregations safely.Last updated2
- Alicense-qualityDmaintenanceEnables AI assistants to interact with MongoDB databases through natural language, supporting document CRUD, aggregation, collection listing, and statistics.Last updated64,747Apache 2.0
Related MCP Connectors
Read-only bank access for your AI agent. Connects Claude, ChatGPT, Cursor, Gemini, Codex.
Read-only MCP server for Muovi, Argentina's trust-first local services marketplace (6 tools).
Gateway between LLM agents and world data through eight tools and a bundled endpoint catalog.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mongodb-developer/mongodb-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server