You signed in with another tab or window. Reload
to refresh your session. You signed out in another tab or window. Reload
to refresh your session. You switched accounts on another tab or window. Reload
to refresh your session. Dismiss alert
ryaker / mongodb-mcp-server Public
A Model Context Protocol server for MongoDB integration with Claude
0 stars
0 forks
Branches
Tags
Activity
Notifications
You must be signed in to change notification settings
main
Go to file
Code
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- |
| Latest commit
-------------
History
-------
1 Commit
| | |
| .env.example | | .env.example | | |
| .gitignore | | .gitignore | | |
| LICENSE | | LICENSE | | |
| README.md | | README.md | | |
| mongo-mcp-server.js | | mongo-mcp-server.js | | |
| package.json | | package.json | | |
| View all files | | |
A Model Context Protocol (MCP) server that provides Claude with the ability to interact with MongoDB databases. This implementation allows Claude to perform aggregations, sample data, and analyze query plans directly from MongoDB collections.
This MongoDB MCP server implements the Model Context Protocol to create a bridge between Claude and MongoDB databases. It enables Claude to execute MongoDB queries and aggregations through a standardized interface, making it possible to analyze and work with your data directly in conversations.
The server exposes three primary tools:
Clone this repository:
shell
git clone https://github.com/yourusername/mongodb-mcp-server.git
cd mongodb-mcp-server
Install dependencies:
shell
npm install
Configure Claude Desktop:
json
"mcpServers": {
"mongo-simple-server": {
"command": "node",
"args": ["/path/to/mongo-mcp-server.js"],
"env": {
"MONGODB_URI": "mongodb+srv://username:password@host",
"DEFAULT_DATABASE": "YourDatabaseName"
}
}
}
Restart Claude Desktop to apply the changes
Ask Claude to sample documents from a collection:
Can you show me 5 random documents from the PEMLeads collection?
Claude will use the sample
tool to retrieve random documents.
Ask Claude to run an aggregation pipeline:
Can you aggregate the PEMLeads collection to count leads by state?
Claude can construct and execute an aggregation pipeline like:
[\
{ "$group": { "_id": "$state", "count": { "$sum": 1 } } },\
{ "$sort": { "count": -1 } }\
]
Ask Claude to analyze a query plan:
Can you explain the performance of an aggregation that finds leads with high value?
Claude can use the explain
tool to analyze the execution plan of a pipeline.
The server connects to MongoDB using environment variables:
MONGODB_URI
: The full MongoDB connection string (required)DEFAULT_DATABASE
: The default database to use (optional, defaults to "GondiCustomerDb")To add new MongoDB functionality:
tools/list
responsetools/call
handlerThe current implementation uses the database specified in the DEFAULT_DATABASE
environment variable. You can extend this to:
If the server fails to connect to MongoDB:
If Claude can't find or use the tools:
The server includes extensive console logging for debugging. Check the Claude Desktop logs for messages from the MongoDB MCP server.
A Model Context Protocol server for MongoDB integration with Claude
No releases published
No packages published
You can’t perform that action at this time.