
How to add MongoDB Lens to Claude Desktop
Full-featured MCP server for querying, aggregating, and managing MongoDB databases via natural language. Paste the config into ~/Library/Application Support/Claude/claude_desktop_config.json and restart Claude Desktop.
Last updated June 14, 2026 ยท 204โ ยท stdio ยท no auth
Claude Desktop config for MongoDB Lens
npx -y mongodb-lens@latest{
"mcpServers": {
"mongodb-lens": {
"command": "/path/to/npx",
"args": [
"-y",
"mongodb-lens@latest",
"mongodb://your-connection-string"
]
}
}
}Setup steps
- 1Open Claude Desktop โ Settings โ Developer โ Edit Config (this opens ~/Library/Application Support/Claude/claude_desktop_config.json).
- 2Paste the MongoDB Lens 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 Lens's tools appear under the ๐ tools menu.
Before you start
- Node.js (>= v18.x; >= v22.x recommended) for NPX/local installation, or Docker
- A running MongoDB instance with a connection string (defaults to mongodb://localhost:27017)
- An MCP-compatible client such as Claude Desktop or Cursor
What MongoDB Lens can do in Claude Desktop
find-documentsRun queries with filters, projections, and sorting.
aggregate-dataExecute aggregation pipelines.
count-documentsCount documents matching specified criteria.
distinct-valuesExtract unique values for any field.
insert-documentInsert one or more documents into collections.
update-documentUpdate documents matching specified criteria.
delete-documentDelete documents matching specified criteria (requires confirmation).
bulk-operationsPerform multiple operations efficiently (requires confirmation for destructive operations).
Security
Permissions are dictated by the MongoDB connection string user; using a read-only account prevents unintended writes/deletes. Destructive operations (drop-collection, drop-database, delete-document, drop-index, drop-user, etc.) require two-step token confirmation by default. This can be bypassed by setting CONFIG_DISABLE_DESTRUCTIVE_OPERATION_TOKENS=true, which executes destructive operations immediately without confirmation. Connection string passwords are obfuscated in logs.
MongoDB Lens + 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 Lens config there under the "mcpServers" key and restart the client.
Is MongoDB Lens safe to use with Claude Desktop?
Permissions are dictated by the MongoDB connection string user; using a read-only account prevents unintended writes/deletes. Destructive operations (drop-collection, drop-database, delete-document, drop-index, drop-user, etc.) require two-step token confirmation by default. This can be bypassed by setting CONFIG_DISABLE_DESTRUCTIVE_OPERATION_TOKENS=true, which executes destructive operations immediately without confirmation. Connection string passwords are obfuscated in logs.
What is the easiest way to run MongoDB Lens?
Run it with NPX: `npx -y mongodb-lens@latest` (optionally followed by your MongoDB connection string). Docker Hub and local Node.js/Docker installs are also supported.
How does it connect to my database?
Pass a MongoDB connection string as an argument (e.g. mongodb://your-connection-string). If omitted, it defaults to mongodb://localhost:27017. You can also define multiple named connection aliases.
How are destructive operations protected?
By default, destructive operations require a two-step token confirmation. You can bypass this in controlled environments by setting CONFIG_DISABLE_DESTRUCTIVE_OPERATION_TOKENS=true. Using a read-only MongoDB user also prevents writes and deletes.