MongoDB MCP Server
Official MongoDB MCP server: queries and aggregations, index management, Atlas clusters and local deployments
Install
npx -y mongodb-mcp-server@latest setupInteractive setup of the connection string or Atlas credentials.
This is third-party code. Review the repository files before installing.
What it does
The server connects the agent to any MongoDB database via a connection string: find, aggregate, count, collection schema and indexes, query explain plans, result export, plus inserting, updating and deleting documents. With Atlas service account credentials it adds tools for projects, clusters, database users, access lists, alerts, the performance advisor and Stream Processing. There are tools for Atlas Local deployments and search over the MongoDB knowledge base. The --readOnly flag keeps only read operations.
Who it is for. For developers and administrators working with MongoDB or MongoDB Atlas.
Good fit when
- You need to explore collection schemas and write an aggregation on real data
- You need to find why a query is slow and pick an index
- You need to create or inspect an Atlas cluster from the agent
Not a fit when
- The project uses a relational database
- The agent must not access production data even read-only
Example request
Show the schema of the orders collection and find which indexes are missing for common queriesLimitations
Requires Node.js 22.13 or later. Atlas tools need service account credentials, which should have minimal permissions. Without --readOnly the agent can delete documents, collections and databases. Atlas may be unavailable from Russia; self-hosted MongoDB works without restrictions.
How to disable. Remove the MongoDB block from your MCP client config or uninstall the mongodb plugin in your agent.
MCP
- Transport
- stdio, http
- Authentication
- API key
| Environment variables | |
|---|---|
| MDB_MCP_CONNECTION_STRING secret | MongoDB connection string |
| MDB_MCP_API_CLIENT_ID secret | Atlas service account client ID for Atlas tools |
| MDB_MCP_API_CLIENT_SECRET secret | Atlas service account client secret |
| MDB_MCP_READ_ONLY | true keeps only read operations |
| MDB_MCP_DISABLED_TOOLS | Tools to disable |
Security check
- Without --readOnly it can delete documents, collections and databases
- Can create and modify Atlas clusters, affecting costs
- Handles connection strings and secrets
README in short
The README offers several install paths: official mongodb and mongodb-atlas plugins for various agents, an interactive setup script, a setup skill and manual config. All config examples include --readOnly. It lists every tool for databases, Atlas, Atlas Local and the knowledge base, plus all configuration options, proxy support and cloud deployment. Apache-2.0 licensed.
FAQ
How do I stop the agent from changing data?
Start with --readOnly or MDB_MCP_READ_ONLY=true; create, update and delete tools are not registered.
Can I avoid running the server locally?
For Atlas there is a MongoDB-hosted server with OAuth, installed as the mongodb-atlas plugin in Cursor, VS Code, Claude and Codex.
Related
166 skills for scientific work: bioinformatics, cheminformatics, clinical data, geospatial analysis and 100+ databases
Google's open-source MCP server for databases: ready tools for Postgres, MySQL, BigQuery, Spanner and more, plus custom tools in tools.yaml
Official Hugging Face skills: Hub operations via the hf CLI, datasets, model training, Spaces, evals and deployment
A token-lean MCP server for PostgreSQL, MySQL, MariaDB, SQL Server and SQLite with a read-only mode