MongoDB MCP Server

Official

Official MongoDB server covering data, schemas and Atlas management — from find queries to spinning up clusters.

Local serverstdiostreamable-httpTypeScriptApache-2.0 900

What is the MongoDB MCP server?

MongoDB's official MCP server covers two jobs that usually need two different tools: working with data (find, aggregate, count, insert, update across any MongoDB deployment) and working with Atlas infrastructure (creating clusters, managing database users, configuring network access) when you connect it with Atlas API credentials.

The data side is what most people come for. Document databases are famously easy to write to and famously annoying to explore — six years of organic schema drift means nobody quite knows what shape orders documents have anymore. The server's schema tools answer that empirically, sampling collections to describe the fields that actually exist. From there, natural-language questions become aggregation pipelines: "monthly revenue by product category from the orders collection" is exactly the kind of query where an assistant writing the pipeline beats you looking up $group syntax for the fourth time.

The Atlas management side is rarer among database MCP servers and genuinely handy for teams living in Atlas: provisioning a dev cluster, rotating a database user, or checking why an IP can't connect happens in the same conversation as the data work.

Configuration deserves attention: flags like --readOnly exist and you should use them by default, only removing restrictions when a task genuinely needs writes. Between connection-string access to any MongoDB (including self-hosted and Community Edition) and API-key access to Atlas, treat scoping as part of setup, not an afterthought.

How it fits a real workflow

  • Open with collection-schema on the collections you care about. It samples real documents rather than reading a declared schema, which is how you find the optional fields and mixed types that quietly break queries written from assumptions.
  • Turn on index checking (--indexCheck) to refuse find and aggregate operations that would trigger a full collection scan — a useful seatbelt when the connection string points somewhere production-sized.
  • Atlas tools only register when service-account credentials are present, so a connection-string-only setup gives you a smaller, purely data-focused toolset by design.
  • Trim what the assistant sees with --disabledTools; fewer tools in context measurably improves which one it reaches for on an ambiguous request.

What you can do with it

Explore drifted schemas

Sample real documents to learn what fields actually exist before writing queries against assumptions.

Natural-language aggregations

Describe the report you want; the assistant writes and runs the pipeline.

Atlas ops in-chat

Provision dev clusters, rotate users and fix network access without opening the Atlas console.

Available tools

ToolWhat it does
findQuery documents in a collection with filters and projections
aggregateRun aggregation pipelines
countCount documents matching a filter
collection-schemaInfer a collection's schema from sampled documents
list-databases / list-collectionsEnumerate what exists on the deployment
insert-many / update-many / delete-manyWrite operations (disabled under --readOnly)
collection-indexesInspect indexes on a collection
atlas-* toolsCreate clusters, manage users and network access (with Atlas credentials)

How to install the MongoDB MCP server

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": ["-y", "mongodb-mcp-server",
               "--connectionString", "mongodb+srv://user:pass@cluster.mongodb.net/mydb",
               "--readOnly"]
    }
  }
}

Drop --readOnly only when you actually need writes.

Configuration

Node.js 20+. A MongoDB connection string, or Atlas service-account credentials for cluster management.

VariableDescriptionRequired
MDB_MCP_CONNECTION_STRINGConnection string alternative to the CLI flage.g. mongodb+srv://user:pass@cluster.mongodb.net/mydbOptional
MDB_MCP_API_CLIENT_IDAtlas service-account client ID (enables Atlas management tools)Optional
MDB_MCP_API_CLIENT_SECRETAtlas service-account client secretOptional

Example prompts to try

  • What collections exist here, and what does a typical document in orders look like?
  • Aggregate total order value by month for the last year.
  • Which collections are missing indexes that these query patterns would need?

Frequently asked questions

Yes — any deployment reachable by connection string: Community Edition, EA, self-hosted replica sets or Atlas. Only the Atlas management tools require Atlas API credentials.