MongoDB MCP server

OfficialMongoDB1,039Config last verified Jun 1, 2026

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

~/.claude.json
json
{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>"
      }
    }
  }
}
Or via CLI
bash
claude mcp add mongodb -- npx -y mongodb-mcp-server@latest --readOnly

Available tools

ToolDescription
connectConnect to a MongoDB instance.
switch-connectionSwitch to a different MongoDB connection.
findRun a find query against a MongoDB collection.
aggregateRun an aggregation against a MongoDB collection.
aggregate-dbRun an aggregation against a MongoDB database.
countGet the number of documents in a collection, with an optional filter.
exportExport query or aggregation results in EJSON format.
insert-manyInsert an array of documents into a collection.
update-manyUpdate all documents matching a filter in a collection.
delete-manyRemove all documents matching a filter from a collection.
create-collectionCreate a new collection, creating the database if needed.
drop-collectionRemove a collection or view and its associated indexes.
rename-collectionRename a collection in a database.
drop-databaseRemove a database and delete its data files.
create-indexCreate an index for a collection.
drop-indexDrop an index for a database and collection.
collection-indexesDescribe the indexes for a collection.
collection-schemaDescribe the schema for a collection.
collection-storage-sizeGet the storage size of a collection.
db-statsReturn statistics on the usage state of a single database.
explainReturn the execution plan chosen by the query optimizer for a method.
list-collectionsList all collections in a database.
list-databasesList all databases for a connection.
mongodb-logsReturn the most recent logged mongod events.
atlas-connect-clusterConnect to a MongoDB Atlas cluster.
atlas-create-clusterCreate a dedicated Atlas cluster (M10–M80).
atlas-create-free-clusterCreate a free (M0) Atlas cluster.
atlas-upgrade-clusterUpgrade an Atlas cluster tier (e.g. M0 to Flex or M10).
atlas-list-clustersList Atlas clusters.
atlas-create-db-userCreate an Atlas database user.
atlas-list-db-usersList Atlas database users.
atlas-create-access-listAllow IP/CIDR ranges to access your Atlas clusters.
atlas-inspect-access-listInspect the IP access list configured for a project.
atlas-create-projectCreate an Atlas project.
atlas-list-projectsList Atlas projects.
atlas-list-orgsList Atlas organizations.
atlas-inspect-clusterInspect the metadata of an Atlas cluster.
atlas-list-alertsList Atlas alerts.
atlas-get-performance-advisorGet Atlas Performance Advisor recommendations including index and schema suggestions.
atlas-streams-buildCreate Atlas Stream Processing resources such as workspaces, connections, and processors.
atlas-streams-discoverDiscover and inspect Atlas Stream Processing resources.
atlas-streams-manageManage Atlas Stream Processing resources: start/stop processors and update configurations.
atlas-streams-teardownDelete Atlas Stream Processing resources.
atlas-local-connect-deploymentConnect to a MongoDB Atlas Local deployment.
atlas-local-create-deploymentCreate a MongoDB Atlas Local deployment.
atlas-local-delete-deploymentDelete a MongoDB Atlas Local deployment.
atlas-local-list-deploymentsList MongoDB Atlas Local deployments.
list-knowledge-sourcesList available data sources in the MongoDB Assistant knowledge base.
search-knowledgeSearch 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.
← Browse all databases servers