MongoDB MCP服务器
STDIO为MongoDB提供只读访问的MCP服务器
为MongoDB提供只读访问的MCP服务器
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.
aggregate
collection
(string): The collection to querypipeline
(array): MongoDB aggregation pipeline stagesoptions
(object): Optional aggregation settings
allowDiskUse
(boolean): Allow operations that require disk usagemaxTimeMS
(number): Maximum execution time in millisecondscomment
(string): Comment to identify the operationexplain
collection
(string): The collection to analyzepipeline
(array): MongoDB aggregation pipeline stagesverbosity
(string): Detail level of the explanation
The server provides schema information for each collection in the database:
mongodb://<host>/<collection>/schema
)
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.
{ "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" } }
{ "collection": "users", "pipeline": [ { "$match": { "age": { "$gt": 21 } } }, { "$sort": { "age": 1 } } ], "verbosity": "executionStats" }
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.