
How to add MCP MongoDB Server to Claude Desktop
Let LLMs query, aggregate, and write to MongoDB with schema inference and read-only protection. Paste the config into ~/Library/Application Support/Claude/claude_desktop_config.json and restart Claude Desktop.
Last updated June 14, 2026 ยท 279โ ยท stdio ยท no auth
Claude Desktop config for MCP MongoDB Server
npx -y mcp-mongo-server mongodb://localhost:27017/database{
"mcpServers": {
"mcp-mongodb-server": {
"command": "npx",
"args": [
"-y",
"mcp-mongo-server",
"mongodb://username:password@localhost:27017/database"
]
}
}
}Setup steps
- 1Open Claude Desktop โ Settings โ Developer โ Edit Config (this opens ~/Library/Application Support/Claude/claude_desktop_config.json).
- 2Paste the MCP MongoDB 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 MCP MongoDB Server's tools appear under the ๐ tools menu.
Before you start
- Node.js with npx (to run the package), or Docker
- A reachable MongoDB instance and a connection URI
What MCP MongoDB Server can do in Claude Desktop
queryExecute MongoDB queries with filter, projection, and limit options, plus an optional explain plan (e.g. executionStats).
aggregateRun MongoDB aggregation pipelines, with an optional explain plan (e.g. queryPlanner).
countCount documents in a collection that match a query.
updateModify documents matching a filter, with upsert and multi options (disabled in read-only mode).
insertInsert one or more new documents into a collection (disabled in read-only mode).
createIndexCreate one or more indexes on a collection, including unique and named indexes (disabled in read-only mode).
serverInfoGet MongoDB server details, with optional debug information.
Security
Credentials are passed through the MongoDB connection URI (in args or the MCP_MONGODB_URI env var), so they will be stored in plaintext in your MCP client config. Use the --read-only flag (or MCP_MONGODB_READONLY="true") to block write operations and route reads to a secondary; read-only mode also disables the update, insert, and createIndex tools.
MCP MongoDB 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 MCP MongoDB Server config there under the "mcpServers" key and restart the client.
Is MCP MongoDB Server safe to use with Claude Desktop?
Credentials are passed through the MongoDB connection URI (in args or the MCP_MONGODB_URI env var), so they will be stored in plaintext in your MCP client config. Use the --read-only flag (or MCP_MONGODB_READONLY="true") to block write operations and route reads to a secondary; read-only mode also disables the update, insert, and createIndex tools.
How do I run it in read-only mode?
Append the --read-only flag to the command args, or set the MCP_MONGODB_READONLY environment variable to "true". Read-only mode blocks write operations and uses a secondary read preference.
How do I provide the MongoDB connection string?
Pass the URI as a positional argument (e.g. npx -y mcp-mongo-server mongodb://user:pass@host:27017/db), or set the MCP_MONGODB_URI environment variable instead of an argument.
Can I use it without npm?
Yes. You can run it directly from GitHub (npx -y github:kiliczsh/mcp-mongo-server ...) or build and run the provided Docker image. Smithery and mcp-get automated installers are also documented.