MongoDB MCP server
MongoDB's official MCP server: query and manage databases, plus Atlas cluster administration.
The MongoDB MCP Server is MongoDB's official integration that connects an agent to both your data and the MongoDB Atlas control plane. Against a live database it can run find queries and aggregation pipelines, count and export documents, insert and update many at once, manage collections and indexes, inspect schemas, storage size, logs, and database stats, and switch between connections. A separate set of Atlas tools provisions and inspects clusters (including free M0 tiers), database users, projects, organizations, IP access lists, alerts, performance-advisor recommendations, Atlas Local deployments, and Stream Processing workspaces. A built-in MongoDB Assistant can also search the official docs and knowledge base.
It runs locally over stdio via npx (mongodb-mcp-server) and connects either with a connection string in MDB_MCP_CONNECTION_STRING or, for Atlas administration, an Atlas API service-account key in MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET. A --readOnly flag limits it to read, connect, and metadata operations, which is the safe default when pointing an agent at production data. The server can also be launched as an HTTP transport for remote use.
Quick install
Copy-paste configs are provided for all 8 supported clients. Pick your client below.
Add to ~/.claude.json
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>"
}
}
}
}claude mcp add mongodb -- npx -y mongodb-mcp-server@latest --readOnlyAvailable tools
| Tool | Description |
|---|---|
| connect | Connect to a MongoDB instance. |
| switch-connection | Switch to a different MongoDB connection. |
| find | Run a find query against a MongoDB collection. |
| aggregate | Run an aggregation against a MongoDB collection. |
| aggregate-db | Run an aggregation against a MongoDB database. |
| count | Get the number of documents in a collection, with an optional filter. |
| export | Export query or aggregation results in EJSON format. |
| insert-many | Insert an array of documents into a collection. |
| update-many | Update all documents matching a filter in a collection. |
| delete-many | Remove all documents matching a filter from a collection. |
| create-collection | Create a new collection, creating the database if needed. |
| drop-collection | Remove a collection or view and its associated indexes. |
| rename-collection | Rename a collection in a database. |
| drop-database | Remove a database and delete its data files. |
| create-index | Create an index for a collection. |
| drop-index | Drop an index for a database and collection. |
| collection-indexes | Describe the indexes for a collection. |
| collection-schema | Describe the schema for a collection. |
| collection-storage-size | Get the storage size of a collection. |
| db-stats | Return statistics on the usage state of a single database. |
| explain | Return the execution plan chosen by the query optimizer for a method. |
| list-collections | List all collections in a database. |
| list-databases | List all databases for a connection. |
| mongodb-logs | Return the most recent logged mongod events. |
| atlas-connect-cluster | Connect to a MongoDB Atlas cluster. |
| atlas-create-cluster | Create a dedicated Atlas cluster (M10–M80). |
| atlas-create-free-cluster | Create a free (M0) Atlas cluster. |
| atlas-upgrade-cluster | Upgrade an Atlas cluster tier (e.g. M0 to Flex or M10). |
| atlas-list-clusters | List Atlas clusters. |
| atlas-create-db-user | Create an Atlas database user. |
| atlas-list-db-users | List Atlas database users. |
| atlas-create-access-list | Allow IP/CIDR ranges to access your Atlas clusters. |
| atlas-inspect-access-list | Inspect the IP access list configured for a project. |
| atlas-create-project | Create an Atlas project. |
| atlas-list-projects | List Atlas projects. |
| atlas-list-orgs | List Atlas organizations. |
| atlas-inspect-cluster | Inspect the metadata of an Atlas cluster. |
| atlas-list-alerts | List Atlas alerts. |
| atlas-get-performance-advisor | Get Atlas Performance Advisor recommendations including index and schema suggestions. |
| atlas-streams-build | Create Atlas Stream Processing resources such as workspaces, connections, and processors. |
| atlas-streams-discover | Discover and inspect Atlas Stream Processing resources. |
| atlas-streams-manage | Manage Atlas Stream Processing resources: start/stop processors and update configurations. |
| atlas-streams-teardown | Delete Atlas Stream Processing resources. |
| atlas-local-connect-deployment | Connect to a MongoDB Atlas Local deployment. |
| atlas-local-create-deployment | Create a MongoDB Atlas Local deployment. |
| atlas-local-delete-deployment | Delete a MongoDB Atlas Local deployment. |
| atlas-local-list-deployments | List MongoDB Atlas Local deployments. |
| list-knowledge-sources | List available data sources in the MongoDB Assistant knowledge base. |
| search-knowledge | Search the MongoDB Assistant knowledge base of docs and curated guidance. |
Required configuration
- MDB_MCP_CONNECTION_STRINGOptional
MongoDB connection string the server connects to for database operations.
- MDB_MCP_API_CLIENT_IDOptional
Atlas API service-account client ID for Atlas administration tools.
- MDB_MCP_API_CLIENT_SECRETOptional
Atlas API service-account client secret for Atlas administration tools.
What you can do with it
Query data in read-only mode
Run the server with --readOnly and a connection string so the agent can run finds and aggregations to answer questions without any write or admin risk.
Administer Atlas from chat
With an Atlas API key, ask the agent to spin up a free cluster, add a database user, allow your IP, and surface Performance Advisor index suggestions.
FAQ
- Is it free?
- Yes. The server is free and open source under Apache 2.0; you only pay for whatever MongoDB or Atlas resources you use, and it can even create free M0 Atlas clusters.
- Does it support remote/OAuth?
- It runs locally over stdio with npx by default, authenticating with a connection string or Atlas API key rather than OAuth. It can also be launched as an HTTP transport for remote/self-hosted setups.