Data as of
MongoDB MCP Server for Claude Code: Setup & Config
Claude Code: MongoDB MCP Server connects AI clients to MongoDB databases and Atlas.
What you can do with MongoDB in Claude Code
A broad MongoDB toolset with read-only onboarding and integrated MongoDB knowledge search.
- Inspect collection schemas and indexes before writing queries.
- Search MongoDB documentation and curated knowledge sources.
Before you start: MongoDB in Claude Code
- Node.js 22.13.0 or later
- A MongoDB connection string or Atlas service-account credentials
- An MCP-compatible client
This is the README's read-only connection-string setup. Atlas operations instead need MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET. Docker and HTTP alternatives are documented; HTTP needs deployment-level authentication and protection.
MongoDB Claude Code configuration
Choose Claude Code configuration scope
For MongoDB MCP Server, open Project scope: .mcp.json at the repository root. Project JSON: merge into mcpServers; user scope: use the CLI.
Add MongoDB MCP Server to Claude Code
Use the mongodb-mcp-server entry below in mcpServers. Keep MongoDB MCP Server's documented stdio connection fields and your other Claude Code entries.
Check MongoDB MCP Server in Claude Code
MongoDB MCP Server: Inspect claude mcp list and /mcp status.
Config file · Project scope: .mcp.json at the repository root
{
"mcpServers": {
"mongodb-mcp-server": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
}
}
}
}claude mcp add-json --scope project 'mongodb-mcp-server' '{"type":"stdio","command":"npx","args":["-y","mongodb-mcp-server@latest","--readOnly"],"env":{"MDB_MCP_CONNECTION_STRING":"<MongoDB connection string with appropriate credentials>"}}'MongoDB tools available to Claude Code
MongoDB's stored tool list documents 27 tools; compare it with Claude Code's connected tool list, because the stored list is not a live check.
- aggregate-db
For MongoDB's aggregate-db, review the permission request and arguments in Claude Code before approval.
- aggregate
For MongoDB's aggregate, review the permission request and arguments in Claude Code before approval.
- collection-indexes
For MongoDB's collection-indexes, review the permission request and arguments in Claude Code before approval.
Inspect indexes attached to a collection.
- collection-schema
For MongoDB's collection-schema, review the permission request and arguments in Claude Code before approval.
Inspect a collection's document structure.
- collection-storage-size
For MongoDB's collection-storage-size, review the permission request and arguments in Claude Code before approval.
Report storage size for a collection.
- connect
For MongoDB's connect, review the permission request and arguments in Claude Code before approval.
Open an independent MongoDB connection and return its identifier.
- count
For MongoDB's count, review the permission request and arguments in Claude Code before approval.
Count collection documents, optionally constrained by a query.
- create-collection
For MongoDB's create-collection, review the permission request and arguments in Claude Code before approval.
Add a collection, creating its database if necessary.
- create-index
For MongoDB's create-index, review the permission request and arguments in Claude Code before approval.
Add an index to a collection.
- db-stats
For MongoDB's db-stats, review the permission request and arguments in Claude Code before approval.
- delete-many
For MongoDB's delete-many, review the permission request and arguments in Claude Code before approval.
- disconnect
For MongoDB's disconnect, review the permission request and arguments in Claude Code before approval.
- drop-collection
For MongoDB's drop-collection, review the permission request and arguments in Claude Code before approval.
- drop-database
For MongoDB's drop-database, review the permission request and arguments in Claude Code before approval.
- drop-index
For MongoDB's drop-index, review the permission request and arguments in Claude Code before approval.
Remove a specified collection index.
- explain
For MongoDB's explain, review the permission request and arguments in Claude Code before approval.
- export
For MongoDB's export, review the permission request and arguments in Claude Code before approval.
- find
For MongoDB's find, review the permission request and arguments in Claude Code before approval.
- insert-many
For MongoDB's insert-many, review the permission request and arguments in Claude Code before approval.
- list-collections
For MongoDB's list-collections, review the permission request and arguments in Claude Code before approval.
- list-connections
For MongoDB's list-connections, review the permission request and arguments in Claude Code before approval.
- list-databases
For MongoDB's list-databases, review the permission request and arguments in Claude Code before approval.
Enumerate databases reachable through a connection.
- mongodb-logs
For MongoDB's mongodb-logs, review the permission request and arguments in Claude Code before approval.
Read recent events logged by mongod.
- rename-collection
For MongoDB's rename-collection, review the permission request and arguments in Claude Code before approval.
Change a collection's name.
- update-many
For MongoDB's update-many, review the permission request and arguments in Claude Code before approval.
Modify collection documents that satisfy a filter.
- list-knowledge-sources
For MongoDB's list-knowledge-sources, review the permission request and arguments in Claude Code before approval.
Discover sources and filtering options in the MongoDB Assistant knowledge base.
- search-knowledge
For MongoDB's search-knowledge, review the permission request and arguments in Claude Code before approval.
Search MongoDB documentation and expert resources with source and version filters.
Troubleshooting MongoDB in Claude Code
- If MongoDB MCP Server fails to start, check npx mongodb-mcp-server@latest (Node.js/npm), the working directory, and Claude Code's selected scope; inspect claude mcp list and /mcp.
- MongoDB MCP Server: check MDB_MCP_CONNECTION_STRING; keep credentials out of shared .mcp.json.
- MongoDB MCP Server uses stdio here: Claude Code must keep the configured process running; protocol output belongs on stdout and diagnostics on stderr.
- Known limitation: Atlas tools require separate service-account credentials.
- Known limitation: HTTP deployments need additional security controls.
- Known limitation: Write-enabled tools can delete data and database objects.
- General Claude Code troubleshooting lives in the /clients/claude-code guide.
MongoDB MCP Server — details. Claude Code guide