MCP Directory

MongoDB MCP Server

Official

Official MongoDB server connecting Atlas, Community, or Enterprise deployments to AI tools.

Verified
stdio (local)
API key
TypeScript

Add to your client

Copy the config for your MCP client and paste it into its config file.

Install / run
npx -y mongodb-mcp-server@latest --readOnly

Paste into ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "mongodb+srv://<user>:<password>@<cluster-host>/<db>"
      }
    }
  }
}

Before you start

  • Node.js v22.13.0 or later (Node 20.x support is deprecated)
  • A MongoDB connection string for the deployment you want to access (Atlas, Community, or Enterprise), OR Atlas API Service Account credentials (Client ID + Secret) for Atlas control-plane tools
  • For Atlas tools: an Atlas Service Account created in the Atlas UI under Access Manager, with the minimum required project/org roles
  • Optionally Docker, if you prefer running the published container image instead of npx

About MongoDB MCP Server

MongoDB MCP Server is the official Model Context Protocol server from MongoDB. It lets AI assistants and agentic tools connect to a MongoDB deployment — Atlas, Community Edition, or Enterprise — and run database operations and Atlas control-plane actions through a standardized set of tools.

It splits its tools into two groups: database tools that operate on your data and collections (find, aggregate, insert, update, schema inspection, index management) and Atlas tools that manage cloud resources through the Atlas Admin API (create clusters, manage projects, database users, and IP access lists). It also bundles MongoDB Assistant knowledge-search tools for answering MongoDB questions from official docs.

The server runs over stdio by default for local MCP clients, and can also serve HTTP for remote connections. A read-only mode, per-query document/byte limits, and tool confirmation requirements let you constrain what an agent is allowed to do.

Tools & capabilities (15)

find

Run a query against a collection and return matching documents

aggregate

Execute an aggregation pipeline on a collection

count

Count documents matching a filter

insert-many

Insert one or more documents into a collection

update-many

Update documents matching a filter

delete-many

Delete documents matching a filter

list-databases

List databases in the connected deployment

list-collections

List collections in a database

collection-schema

Infer and return the schema of a collection

create-index

Create an index on a collection

explain

Return the query/aggregation execution plan

atlas-create-cluster

Provision a new Atlas cluster (also atlas-create-free-cluster)

atlas-list-clusters

List clusters in an Atlas project

atlas-create-access-list

Add an IP/CIDR to a project's Atlas access list

search-knowledge

Search MongoDB documentation knowledge sources via the MongoDB Assistant

When to use it

  • Use it when you want an AI agent to explore an unfamiliar MongoDB database — listing collections, inferring schemas, and counting documents — without writing queries by hand
  • Use it when you need to run ad-hoc finds and aggregations in natural language during debugging or analysis
  • Use it when provisioning or managing Atlas resources (clusters, projects, DB users, IP access lists) from your AI tooling instead of the Atlas UI
  • Use it when you want index and query-plan advice — inspecting indexes, running explain, and checking the performance advisor
  • Use it when you want a read-only, guard-railed connection so an assistant can inspect production data safely

Quick setup

  1. 1Choose your credential: a MongoDB connection string (set MDB_MCP_CONNECTION_STRING), or Atlas Service Account Client ID + Secret for Atlas tools
  2. 2Add the server to your MCP client config using npx (command: npx, args: -y mongodb-mcp-server) or the Docker image
  3. 3Pass the connection string / Atlas credentials via environment variables or CLI args
  4. 4Optionally set --readOnly and document/byte limits to constrain agent behavior
  5. 5Restart your MCP client and confirm the mongodb tools appear, then run list-databases to verify the connection

Security notes

The connection string carries full database credentials, so keep it in env vars (never args) and use a scoped user. Pass --readOnly when the agent should not mutate or drop collections.

MongoDB MCP Server FAQ

Does it work with self-hosted MongoDB or only Atlas?

Both. Database tools work against any MongoDB deployment via a connection string — Atlas, Community, or Enterprise. The atlas-* tools additionally require Atlas Service Account API credentials and only apply to Atlas.

How do I get Atlas API credentials?

Create a Service Account in the Atlas UI (Organization/Project Access Manager > Applications), copy the Client ID and Client Secret, and grant it the minimum roles needed for the operations you want to perform.

Can I stop an agent from modifying data?

Yes. Start the server with read-only mode enabled and it will only expose non-destructive tools. You can also require confirmation for specific tools and cap how many documents/bytes a query returns.

What Node version do I need?

Node.js v22.13.0 or later. Node 20.x still runs but is deprecated, so upgrade to avoid future breakage.

Alternatives to MongoDB MCP Server

Google's official MCP server with prebuilt BigQuery tools, querying datasets via Application Default Credentials.

Verified
stdio (local)
OAuth
Go
10 tools
Updated 11 days agoRepo

Read/write Postgres access plus index tuning, EXPLAIN plans, and database health analysis for AI agents.

Verified
stdio (local)
API key
Python
9 tools
Updated 3 months agoRepo

Official Supabase server: manage tables, run SQL, branches, configs and edge functions from your AI client.

Verified
HTTP (remote)
OAuth
TypeScript
12 tools
Updated 1 month agoRepo