MongoDB MCP Server

Query and manage MongoDB databases and MongoDB Atlas clusters, projects and users from an assistant

Official · mongodb-js TypeScript Local · stdio DatabasesCloud platforms

93 popularity score ★ 1.2k ↓ 157k/wk

Connect your client

Local (npm)

Add in one click

Opens the app, which asks before it adds the server.

Or add it by command or config

Claude CodeTerminal
claude mcp add mongodb -- npx -y mongodb-mcp-server@latest --readOnly
Claude Desktopclaude_desktop_config.json
{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ]
    }
  }
}
Cursor~/.cursor/mcp.json
{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ]
    }
  }
}
VS Code.vscode/mcp.json
{
  "servers": {
    "mongodb": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ]
    }
  }
}
Codex~/.codex/config.toml
[mcp_servers.mongodb]
command = "npx"
args = ["-y", "mongodb-mcp-server@latest", "--readOnly"]
Gemini CLITerminal
gemini mcp add --scope user mongodb npx -- -y mongodb-mcp-server@latest --readOnly
Local (Docker)

Add in one click

Opens the app, which asks before it adds the server.

Or add it by command or config

Claude CodeTerminal
claude mcp add mongodb -- docker run --rm -i mongodb/mongodb-mcp-server:latest
Claude Desktopclaude_desktop_config.json
{
  "mcpServers": {
    "mongodb": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "mongodb/mongodb-mcp-server:latest"
      ]
    }
  }
}
Cursor~/.cursor/mcp.json
{
  "mcpServers": {
    "mongodb": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "mongodb/mongodb-mcp-server:latest"
      ]
    }
  }
}
VS Code.vscode/mcp.json
{
  "servers": {
    "mongodb": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "mongodb/mongodb-mcp-server:latest"
      ]
    }
  }
}
Codex~/.codex/config.toml
[mcp_servers.mongodb]
command = "docker"
args = ["run", "--rm", "-i", "mongodb/mongodb-mcp-server:latest"]
Gemini CLITerminal
gemini mcp add --scope user mongodb docker -- run --rm -i mongodb/mongodb-mcp-server:latest

Settings 3

MDB_MCP_CONNECTION_STRING secret Optional: Deprecated single connection string, used as the preconfigured connection. MDB_MCP_CONNECTION_STRINGS, a JSON object of named strings, replaces it. With neither set the assistant must call connect first.
Set together: atlas
MDB_MCP_API_CLIENT_ID Optional: Atlas service account client ID, needed for the atlas- tools. For Atlas tools.
MDB_MCP_API_CLIENT_SECRET secret Optional: Atlas service account client secret, paired with the client ID. For Atlas tools.

In a container, a setting goes in with -e NAME=value after docker run.

What it does

This is MongoDB's own server for working with MongoDB from an assistant. Point it at a deployment with a connection string, or have the assistant call connect later, and it can browse databases and run find queries or aggregation pipelines. It will also infer a collection's schema, show indexes and explain plans, or export results to EJSON files. Writes are on by default too, down to dropping whole databases. Any MongoDB deployment works, self-hosted or on Atlas.

Give it an Atlas service account (client ID and secret) and a second set of tools turns on for Atlas itself. Those cover clusters (create, inspect, pause, upgrade), database users and IP access lists. You also get Performance Advisor output, alerts, and setting up or tearing down Stream Processing. There are also tools for Atlas Local deployments running in Docker and a search over MongoDB's Assistant knowledge base.

Out of the box the find tool hands back 10 documents per call. The server caps find and aggregate at 100 documents and 16 MB per call, and a single find reply at 1 MB unless the assistant asks for more (find.ts and the config schema). It ships 53 tools in all.

A few settings have new names. The single connection string is giving way to MDB_MCP_CONNECTION_STRINGS, a JSON object of named strings where each name turns into a connectionId the tools can use, so one server can talk to several deployments. The old string now just fills the entry called preconfigured, and the config schema rejects setting both. The timeouts moved as well: maxTimeMS is now timeoutMs, and the two count caps are queryCountTimeoutMs and aggregationCountTimeoutMs. The old names still work for now but are deprecated.

What it needs

RuntimeNode.js 20.19+
Runs onmacOS, Windows, Linux
MongoDBYour own instanceAny reachable deployment. The Atlas tools need an Atlas service account with API credentials.

Node 22.13 or later is what the README asks for. The package still accepts Node 20.19, but Node 20 support is deprecated and due to be dropped. The Docker image needs no local Node. For the Atlas tools, create a service account in Atlas, give it only the permissions you need, and pass its client ID and secret as environment variables. Other settings use the MDB_MCP_ prefix with the option name in upper snake case, for example MDB_MCP_READ_ONLY=true, MDB_MCP_TELEMETRY=disabled or MDB_MCP_AGGREGATION_COUNT_TIMEOUT_MS (60000 ms by default).

Limits

  • Size cap find and aggregate return at most 100 documents and 16 MB per call by default (MDB_MCP_MAX_DOCUMENTS_PER_QUERY, MDB_MCP_MAX_BYTES_PER_QUERY)
  • Size cap find returns 10 documents unless limit is set, and a reply is cut at 1 MB unless responseBytesLimit is raised
  • Limit The atlas- tools only appear once an Atlas client ID and secret are configured
  • Limit Server-side JavaScript operators such as $where and $function are refused unless MDB_MCP_DISABLE_SERVER_SIDE_JS is set to false
  • Limit Confirmation prompts for destructive tools only work in clients that support elicitation
  • Early release atlas-local-create-deployment uses the preview Atlas Local image unless a tag is given
  • Limit MDB_MCP_CONNECTION_STRING is deprecated in favour of the preconfigured entry of MDB_MCP_CONNECTION_STRINGS, and setting both is rejected
  • Limit MDB_MCP_CONNECTION_STRINGS can only be set as an environment variable or in the config file, with no command-line flag
  • Limit MDB_MCP_MAX_TIME_M_S, MDB_MCP_QUERY_COUNT_MAX_TIME_MS_CAP and MDB_MCP_AGGREGATION_COUNT_MAX_TIME_MS_CAP are deprecated. MDB_MCP_CONNECTION_SCOPE is due to be removed, and connections will then be shared across sessions
  • Cost Clusters created through the Atlas tools other than free ones are billed to the Atlas account

Who it suits

A good fit for developers who want an assistant to explore, query or tidy up a MongoDB database they already run, local or on Atlas, and for Atlas users who want cluster, user and access list chores handled from the same place. Because it runs on your own machine with your own credentials, it suits one person at a time. For shared or multi-user Atlas access, MongoDB points to its Atlas-Managed MCP server, a hosted endpoint at mcp.mongodb.com that handles sign-in per user. If you only need to read data, start it with --readOnly as the README's examples do.

Tools 53

30 only read, 17 change things, 6 can delete or overwrite. A ? marks an optional parameter.

aggregate
Runs an aggregation pipeline on one collection
aggregate-db
Runs a database-level aggregation pipeline
collection-indexes
Lists the indexes defined on a collection
collection-schema
Samples a collection and reports its inferred schema
collection-storage-size
Reports how much storage a collection uses
connect
Opens a connection to a MongoDB deployment from a connection string
count
Counts documents in a collection, with an optional filter
create-collection changes
Creates a collection, and its database if that is missing
create-index changes
Adds an index to a collection
db-stats
Returns usage statistics for one database
delete-many deletes
Deletes every document matching a filter
disconnect
Closes a connection and invalidates its connectionId
drop-collection deletes
Drops a collection or view together with its indexes
drop-database deletes
Drops a whole database and its data files
drop-index deletes
Removes an index from a collection
explain
Shows the query planner's winning plan and execution stats
export changes
Saves find or aggregation results to an EJSON export file
find
Runs a find query, returning 10 documents unless limit says otherwisedatabase: stringcollection: stringfilter?: objectprojection?: objectlimit?: numbersort?: objectresponseBytesLimit?: number
insert-many changes
Inserts a batch of documents into a collection
list-collections
Lists the collections in a database
list-connections
Lists open connections with their connectionIds
list-databases
Lists the databases on a connection
mongodb-logs
Returns recent mongod log entries
rename-collection changes
Gives a collection a new name
update-many changes
Applies an update to every document matching a filter
atlas-connect-cluster
Opens a new connection to an Atlas cluster and returns its connectionId
atlas-create-access-list changes
Adds IP addresses or CIDR ranges to a project's access list
atlas-create-cluster changes
Creates a dedicated M10 to M80 Atlas cluster with autoscaling on
atlas-create-db-user changes
Creates a database user in an Atlas project
atlas-create-free-cluster changes
Creates a free-tier Atlas cluster
atlas-create-project changes
Creates an Atlas project
atlas-get-performance-advisor
Fetches index and schema suggestions plus up to 50 recent slow queries
atlas-get-regions
Lists the Atlas regions offered for a cloud provider
atlas-inspect-access-list
Shows the IP and CIDR entries allowed into a project
atlas-inspect-cluster
Shows a cluster's metadata and state
atlas-list-alerts
Lists alerts Atlas has raised for a project, open ones by default
atlas-list-clusters
Lists Atlas clusters
atlas-list-db-users
Lists database users in an Atlas project
atlas-list-orgs
Lists the Atlas organizations the credentials can see
atlas-list-projects
Lists Atlas projects
atlas-load-sample-dataset changes
Starts loading a sample dataset into a cluster, or checks a running load
atlas-pause-resume-cluster changes
Pauses or resumes a dedicated M10+ cluster
atlas-streams-build changes
Creates Stream Processing workspaces, connections, processors or PrivateLink
atlas-streams-discover
Lists and inspects Stream Processing resources and processor health
atlas-streams-manage changes
Starts, stops and reconfigures stream processors and workspaces
atlas-streams-teardown deletes
Deletes Stream Processing workspaces, connections or processors
atlas-upgrade-cluster changes
Moves a cluster to a bigger tier or changes its autoscaling
atlas-local-connect-deployment
Connects to an Atlas Local deployment and returns a connectionId
atlas-local-create-deployment changes
Starts a new Atlas Local deployment, on the preview image by default
atlas-local-delete-deployment deletes
Removes an Atlas Local deployment
atlas-local-list-deployments
Lists Atlas Local deployments
list-knowledge-sources
Lists the data sources in the MongoDB Assistant knowledge base
search-knowledge
Searches MongoDB docs and guidance in the Assistant knowledge base

Resources 3

config://config
The server's current settings, with secrets redacted
debug://mongodb
Details of the last connection attempt and its error, for troubleshooting
exported-data://{exportName}
Data written by the export tool, by export name

Similar servers