Skip to content

Menu

MongoDB MCP Server logo

MongoDB MCP Server

Published · Updated

At a glance

Category
Databases
Watch out for
Read-only is not the default; you have to pass --readOnly yourself, which is easy to forget when copying a config.

The MongoDB MCP Server is MongoDB's official server for both databases and MongoDB Atlas. It moved from the mongodb-labs organisation to mongodb-js, published on npm as mongodb-mcp-server. It covers two quite different jobs: working with the data in a database (finding, aggregating, inserting, indexing) and managing Atlas itself (projects, clusters, users, access lists and the Performance Advisor).

What sets it apart is how seriously it treats safety. Every example in the README includes --readOnly, with a note that you should remove it only if you really want writes. Destructive tools such as drop-database, drop-collection and delete-many are on a default list of tools that require confirmation before they run, as long as your client supports MCP elicitation. There are also options to disable tools or whole categories, and to reject queries that would not use an index, which protects a busy cluster from collection scans.

MongoDB now also offers a hosted Atlas MCP server over OAuth, packaged as the mongodb-atlas plugin for Cursor, VS Code, Claude, Codex and others. For Atlas, that is the recommended route because nothing runs locally. The local server, packaged as the mongodb plugin, is the one to use for self-managed deployments or a local database.

How it connects

Your AI app

An assistant or agent that supports MCP

MongoDB MCP Server

Runs as

  • npx (Node.js)
  • Remote (HTTP)

Gives the agent

  • Query and aggregation
  • Schema and index insight
  • Writes and administration
  • Atlas management
  • Guard rails

MongoDB

Signs in with

  • OAuth / browser sign-in
Your AI app talks to MongoDB MCP Server over the Model Context Protocol, and the server carries out the work. Built from the setup and capability sections on this page.

What it can do

Query and aggregation
find, aggregate, count and explain let the model read data and check how a query will execute. export writes results out in EJSON.
Schema and index insight
collection-schema infers the shape of documents, collection-indexes lists indexes, and db-stats and collection-storage-size show how big things are.
Writes and administration
insert-many, create-index, create-collection, delete-many and the drop tools are available when read-only mode is off; the destructive ones ask for confirmation by default.
Atlas management
Tools such as atlas-list-clusters, atlas-create-free-cluster, atlas-create-db-user, atlas-inspect-access-list and atlas-get-performance-advisor manage Atlas through its API.
Guard rails
readOnly, confirmationRequiredTools, disabledTools and indexCheck can be set as flags or MDB_MCP_* environment variables.

Setting it up

The quickest local setup is npx -y mongodb-mcp-server@latest setup, which walks you through configuring your client. To configure it by hand, run npx -y mongodb-mcp-server@latest --readOnly and pass the connection string in the MDB_MCP_CONNECTION_STRING environment variable, for example mongodb://localhost:27017/myDatabase. Atlas management tools need Atlas service account credentials, set as MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET, rather than a connection string. The README recommends Node.js 22.13 or later, since Node 20 support is deprecated. For Atlas, the simpler option is the hosted server through the mongodb-atlas plugin, which signs in with OAuth.

Run in a terminal
claude mcp add mongodb -- npx -y mongodb-mcp-server@latest

Runs the mongodb-mcp-server package from npm. Add any API keys, environment variables or extra arguments the setup notes above list. Combine several servers in the MCP config generator

Where each client keeps its MCP config file, and the JSON it expects (cheat sheet)

Where it helps

  • Exploring an unfamiliar database: listing collections, inferring schemas and sampling documents
  • Writing and testing an aggregation pipeline with explain output to check index use
  • Asking the Performance Advisor for index suggestions on a slow Atlas cluster
  • Spinning up a free Atlas cluster with a database user for a prototype
  • Exporting query results for a quick analysis

Limitations and things to watch

  • Read-only is not the default; you have to pass --readOnly yourself, which is easy to forget when copying a config.
  • Documents returned from the database are untrusted text; a field containing instructions can still influence the model.
  • Atlas tools need separate API credentials and act on real infrastructure, including creating clusters that may cost money.
  • Large result sets can fill the context quickly; filter and limit queries.

Sources

Written from the project's own documentation, checked November 2026.

How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…