
How to add MongoDB MCP Server to Claude Desktop
Official MongoDB server connecting Atlas, Community, or Enterprise deployments to AI tools. Paste the config into ~/Library/Application Support/Claude/claude_desktop_config.json and restart Claude Desktop.
Last updated June 15, 2026 ยท 1.5kโ ยท stdio ยท apikey ยท official
Claude Desktop config for MongoDB MCP Server
npx -y mongodb-mcp-server@latest --readOnly{
"mcpServers": {
"mongodb-mcp-server": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://<user>:<password>@<cluster-host>/<db>"
}
}
}
}Setup steps
- 1Open Claude Desktop โ Settings โ Developer โ Edit Config (this opens ~/Library/Application Support/Claude/claude_desktop_config.json).
- 2Paste the MongoDB MCP Server config below under the top-level "mcpServers" key.
- 3Fill in any placeholder secrets (API keys, paths) in the snippet.
- 4Save the file, then fully quit and reopen Claude Desktop.
- 5Open a chat and confirm MongoDB MCP Server's tools appear under the ๐ tools menu.
Before you start
- Node.js v22.13.0 or later (Node 20.x support is deprecated)
- A MongoDB connection string for the deployment you want to access (Atlas, Community, or Enterprise), OR Atlas API Service Account credentials (Client ID + Secret) for Atlas control-plane tools
- For Atlas tools: an Atlas Service Account created in the Atlas UI under Access Manager, with the minimum required project/org roles
- Optionally Docker, if you prefer running the published container image instead of npx
What MongoDB MCP Server can do in Claude Desktop
findRun a query against a collection and return matching documents
aggregateExecute an aggregation pipeline on a collection
countCount documents matching a filter
insert-manyInsert one or more documents into a collection
update-manyUpdate documents matching a filter
delete-manyDelete documents matching a filter
list-databasesList databases in the connected deployment
list-collectionsList collections in a database
Security
The connection string carries full database credentials, so keep it in env vars (never args) and use a scoped user. Pass --readOnly when the agent should not mutate or drop collections.
MongoDB MCP Server + Claude Desktop FAQ
Where is the Claude Desktop config file?
Claude Desktop reads MCP servers from ~/Library/Application Support/Claude/claude_desktop_config.json. Paste the MongoDB MCP Server config there under the "mcpServers" key and restart the client.
Is MongoDB MCP Server safe to use with Claude Desktop?
The connection string carries full database credentials, so keep it in env vars (never args) and use a scoped user. Pass --readOnly when the agent should not mutate or drop collections.
Does it work with self-hosted MongoDB or only Atlas?
Both. Database tools work against any MongoDB deployment via a connection string โ Atlas, Community, or Enterprise. The atlas-* tools additionally require Atlas Service Account API credentials and only apply to Atlas.
How do I get Atlas API credentials?
Create a Service Account in the Atlas UI (Organization/Project Access Manager > Applications), copy the Client ID and Client Secret, and grant it the minimum roles needed for the operations you want to perform.
Can I stop an agent from modifying data?
Yes. Start the server with read-only mode enabled and it will only expose non-destructive tools. You can also require confirmation for specific tools and cap how many documents/bytes a query returns.