MongoDB MCP server

The MongoDB MCP server gives AI agents access to MongoDB databases and MongoDB Atlas: run find and aggregate queries, inspect schemas and indexes, and create or manage Atlas clusters and users.

Checked by CookiesForAI on : repository facts (stars, last push, archived) re-read from GitHub; listing in the MCP Registry checked.

Written by

Connect MongoDB

Interactive setup for the local server

Terminal
npx -y mongodb-mcp-server@latest setup

Any client with a JSON config, read-only, with a connection string

Config
{"mcpServers": {"MongoDB": {"command": "npx", "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"], "env": {"MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase"}}}}

Codex, as a plugin from MongoDB's marketplace (then install mongodb in /plugins)

Terminal
codex plugin marketplace add mongodb/agent-skills

GitHub Copilot CLI, managed Atlas server through the plugin

Terminal
copilot plugin install mongodb-atlas

For Atlas, MongoDB recommends the mongodb-atlas plugin, available in the Claude, Cursor, VS Code, Codex, Copilot CLI and Grok Build marketplaces, which signs in with OAuth. MongoDB advises passing connection strings and API credentials as environment variables, not command-line arguments.

Or paste this into your coding agent: Connect the MongoDB MCP server to my coding agent using its documented setup: https://github.com/mongodb-js/mongodb-mcp-server. Checked by CookiesForAI on : repository facts (stars, last push, archived) re-read from GitHub; listing in the MCP Registry checked.

What the MongoDB MCP server does

The MongoDB MCP server is MongoDB's own server for connecting AI agents to MongoDB. With a connection string, the agent can list databases and collections, infer a collection's schema, run find, count and aggregation queries, explain a query plan, and read indexes and storage sizes. Write tools insert, update and delete documents, create collections and indexes, and drop them, and an export tool saves query results to a file.

MongoDB's server also manages MongoDB Atlas through the Atlas API. The agent can list and inspect organizations, projects and clusters, create a free cluster, add database users and IP access entries, load sample data, pause or upgrade a cluster, read alerts and the performance advisor, and work with Atlas Stream Processing. Atlas Local tools create and connect to a local Atlas deployment in Docker, and assistant tools search MongoDB's knowledge sources.

The server runs locally through npx with Node.js 22.13 or newer, or in Docker. MongoDB also runs a managed Atlas MCP server reached through its mongodb-atlas plugin with OAuth. All of MongoDB's setup examples start in read-only mode. The GitHub repo had 1,138 stars on .

Tools it gives your agent

  • find
  • aggregate
  • count
  • collection-schema
  • collection-indexes
  • explain
  • insert-many
  • update-many
  • create-index
  • atlas-list-clusters
  • atlas-create-free-cluster
  • atlas-get-performance-advisor

When to use MongoDB

  • You want the agent to understand the real shape of your documents before it writes queries.
  • You need an aggregation pipeline written and checked against your data.
  • You want to create a free Atlas cluster and a database user for a new project from your editor.
  • You want to see slow queries and index suggestions from the Atlas performance advisor.

When to pick something else

  • Running without read-only mode on important data: write tools can delete many documents or drop whole databases, so keep --readOnly unless you need writes.

What MongoDB needs

  • Node.js 22.13 or newer, or Docker
  • A MongoDB connection string, or Atlas service account credentials for Atlas tools

What the MongoDB MCP server costs

Free and open source under Apache-2.0; database use is billed by MongoDB Atlas, which has a free cluster tier, or free on your own servers.

Current prices: www.mongodb.com . We do not list prices because vendors change them often. Check the publisher's own page.

Questions people ask

Is the MongoDB MCP server free?

Yes. It is open source under Apache-2.0. You pay only for MongoDB itself, and Atlas has a free cluster tier (pricing page, ).

Can the MongoDB MCP server delete data?

Yes, unless you run it read-only. Its tools include delete-many, drop-collection and drop-database. The --readOnly flag or MDB_MCP_READ_ONLY=true removes every create, update and delete tool.

Does it work with self-hosted MongoDB, not only Atlas?

Yes. The local server connects to any MongoDB deployment by connection string; the Atlas tools are extra and need Atlas credentials.