MongoDB MCP Server
Overview
MongoDB MCP Server is a Model Context Protocol server that provides read-only access to MongoDB databases, allowing LLMs (Large Language Models) to inspect collection schemas and execute aggregation pipelines effectively.
To use the MongoDB MCP Server, configure the server in the 'mcpServers' section of your 'claude_desktop_config.json' file with your MongoDB URI. You can then execute aggregation queries and analyze execution plans to obtain insights about your data.
- Read-only access to MongoDB databases - Execute MongoDB aggregation pipelines - Retrieve execution plans for query optimization - Automatic schema inference from collection documents - Safety features such as document limits and operation timeouts
- Analyzing user demographics stored in a MongoDB database.
- Generating statistics on product sales by category.
- Executing complex queries for data analysis in research projects.
Add to your AI client
Use these steps to connect MongoDB MCP Server in Cursor, Claude, VS Code, and other MCP-compatible apps. The same JSON appears in the Use with menu above for one-click copy.
Cursor
Add this to your .cursor/mcp.json file in your project root, then restart Cursor.
.cursor/mcp.json
{
"mcpServers": {
"mongodb-mcp-server-mongodb-developer": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mongodb-mcp-server-mongodb-developer"
]
}
}
}Claude Desktop
Add this server entry to the mcpServers object in your Claude Desktop config, then restart the app.
~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
{
"mcpServers": {
"mongodb-mcp-server-mongodb-developer": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mongodb-mcp-server-mongodb-developer"
]
}
}
}Claude Code
Add this to your project's .mcp.json file. Claude Code will detect it automatically.
.mcp.json (project root)
{
"mcpServers": {
"mongodb-mcp-server-mongodb-developer": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mongodb-mcp-server-mongodb-developer"
]
}
}
}VS Code (Copilot)
Add this to your .vscode/mcp.json file. Requires the GitHub Copilot extension with MCP support enabled.
.vscode/mcp.json
{
"servers": {
"mongodb-mcp-server-mongodb-developer": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mongodb-mcp-server-mongodb-developer"
]
}
}
}Windsurf
Add this to your Windsurf MCP config file, then restart Windsurf.
~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"mongodb-mcp-server-mongodb-developer": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mongodb-mcp-server-mongodb-developer"
]
}
}
}Cline
Open Cline settings, navigate to MCP Servers, and add this server configuration.
Cline MCP Settings (via UI)
{
"mcpServers": {
"mongodb-mcp-server-mongodb-developer": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mongodb-mcp-server-mongodb-developer"
]
}
}
}FAQ
Is this server compatible with all MongoDB versions?
Yes, the server is designed to work with various versions of MongoDB, as long as they support the aggregation framework.
Can I perform write operations using this server?
No, this server is strictly read-only to ensure data integrity and safety.
How do I configure connection settings?
You need to set the 'MONGODB_URI' in your 'claude_desktop_config.json' to connect to your MongoDB instance.7:["$","div",null,{"className":"container mx-auto flex flex-col gap-4","children":["$L26","$L27",["$","$L28",null,{"currentProject":{"id":414,"uuid":"87846c2c-ae44-4d48-9114-b84a34903efb","name":"mongodb-mcp-server","title":"MongoDB MCP Server","description":"","avatar_url":"https://avatars.githubusercontent.com/u/45798453?v=4","created_at":"2024-12-15T06:47:00.649Z","updated_at":"2024-12-16T06:52:40.650Z","status":"created","author_name":"mongodb-developer","author_avatar_url":"https://avatars.githubusercontent.com/u/45798453?v=4","tags":"[]","category":"research-and-data","is_featured":false,"sort":1,"url":"https://github.com/mongodb-developer/mongodb-mcp-server","target":"_self","content":"$29","summary":"$2a","img_url":null,"type":null,"metadata":"{\"star\":\"21\",\"license\":\"\",\"language\":\"JavaScript\",\"is_official\":false,\"latest_commit_time\":\"2025-04-30 09:28:28\"}","user_uuid":null,"tools":null,"sse_url":null,"sse_provider":null,"sse_params":null,"is_official":false,"server_command":null,"server_params":null,"server_config":null,"allow_call":false,"is_innovation":false,"is_dxt":false,"dxt_manifest":null,"dxt_file_url":null,"is_audit":false},"randomProjects":[],"currentServerKey":"$undefined"}]]}]