MongoDB MCP Server: Query MongoDB and Atlas with Claude
MongoDB's official MCP server lets Claude query collections, inspect schemas and indexes, and manage Atlas clusters. Setup, read-only mode, use cases, caveats.
By Claudekit Team Published 2 min read
- Type
- MCP Server
- Pricing
- Freemium
- Repository
- github.com
- GitHub stars
- 1,151
- Website
- mongodb.com
The MongoDB MCP Server is MongoDB’s official Model Context Protocol server for MongoDB databases and MongoDB Atlas. It lets Claude run find and aggregation queries, describe collection schemas and indexes, explain query plans, and, with Atlas credentials, list and manage clusters, projects and database users.
Who it is for
Developers who use MongoDB locally or on Atlas and want Claude Code to understand their real data shape before writing queries or index changes.
Install
The README offers three routes. The simplest is the interactive setup script, which asks for your connection string or Atlas API credentials:
npx -y mongodb-mcp-server@latest setup
The README also lists official MongoDB plugins for Claude: mongodb-atlas connects to the hosted Atlas MCP server over OAuth, and mongodb runs the server locally for self-managed deployments.
For manual setup, the README’s config with a connection string looks like this. It works as a project .mcp.json in Claude Code:
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": ["-y", "mongodb-mcp-server@latest", "--readOnly"],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase"
}
}
}
}
MongoDB recommends environment variables over command-line arguments for secrets, because arguments can show up in process lists and logs.
Use cases
- Understand data: “Describe the schema of the orders collection and show a sample document.”
- Query help: Claude writes and runs an aggregation, then explains the result.
- Index tuning: run
explainon a slow query and ask for an index suggestion. - Atlas admin: list clusters, check alerts or read Performance Advisor tips.
Pros
- Official, Apache-2.0 licensed and actively released.
- Read-only mode in every documented example.
- Covers local MongoDB, Atlas, Atlas Local and Atlas Stream Processing.
- Includes a MongoDB knowledge-base search tool for docs questions.
Cons and caveats
- Write tools include
drop-databaseanddelete-many. Keep--readOnlyunless you need writes. - Atlas tools need a service account. Give it only the minimum permissions.
- The hosted Atlas server needs a client with OAuth, or the separate
mongodb-atlas-mcp-remotepackage. - Large query results use up context. Ask for counts or samples first.
Links
- Repo: mongodb-js/mongodb-mcp-server
- Docs: MongoDB MCP Server
- Package: mongodb-mcp-server on npm
- Related: DBHub, Supabase MCP, MCP servers guide
Checked 24 Oct 2026 against the vendor repo, the MongoDB docs and the MCP registry.
Frequently asked questions
Does it work with self-hosted MongoDB?
Yes. Pass any MongoDB connection string, local or Atlas, through the MDB_MCP_CONNECTION_STRING environment variable.
When do the Atlas tools appear?
Only when you set Atlas service account credentials (MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET). With just a connection string you get the database tools.
Is there a read-only mode?
Yes. The README examples all include --readOnly by default. Remove it only if you need write operations.
What Node.js version does it need?
The README lists Node.js 22.13.0 or later. Node 20 support is deprecated.