---
title: "MongoDB MCP server: query collections and manage Atlas with AI agents"
canonical_url: https://cookiesforai.app/mcp/mongodb
last_updated: 2026-10-03T10:04:47+02:00
type: mcp
summary: "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."
install: "npx -y mongodb-mcp-server@latest setup"
related:
  - "https://cookiesforai.app/mcp/dbhub"
  - "https://cookiesforai.app/mcp/neon"
  - "https://cookiesforai.app/mcp/postgres-mcp-pro"
  - "https://cookiesforai.app/mcp/redis"
---

# 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.

| Fact | Value |
|---|---|
| Publisher | MongoDB (official) |
| Source | https://github.com/mongodb-js/mongodb-mcp-server |
| License | Apache-2.0 |
| GitHub stars | 1,138 on 2026-10-02 |
| Last code push | 2026-10-01 |
| Page updated | 2026-10-03 |
| Official MCP Registry | io.github.mongodb-js/mongodb-mcp-server |
| Documented clients | Claude Code, Claude Desktop, Claude.ai, Codex, Cursor, VS Code, GitHub Copilot CLI, Gemini CLI, Grok Build, Devin |
| Category | Databases |
| Free tier | Free plan |
| Cost | 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 | https://www.mongodb.com/pricing |
| Facts checked | 2026-10-02 |

## Connect

Interactive setup for the local server:

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

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

```
{"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):

```
codex plugin marketplace add mongodb/agent-skills
```

GitHub Copilot CLI, managed Atlas server through the plugin:

```
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.

## Ask your coding agent

```text
Connect the MongoDB MCP server to my coding agent using its documented setup: https://github.com/mongodb-js/mongodb-mcp-server.
```

## What it 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 2026-10-01.

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 it

- 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 it needs

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

## 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, 2026-10-01).

### 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.

## Related

### Other MCP servers for databases

- [DBHub](https://cookiesforai.app/mcp/dbhub): DBHub is an open-source MCP server by Bytebase that gives AI agents SQL access to PostgreSQL, MySQL, MariaDB, SQL Server, Oracle and SQLite through one server with two default tools.
- [Neon](https://cookiesforai.app/mcp/neon): The Neon MCP server gives AI agents control of Neon serverless Postgres: create projects and branches, run SQL, inspect schemas, find slow queries and run migrations on a branch before applying them.
- [Postgres MCP Pro](https://cookiesforai.app/mcp/postgres-mcp-pro): Postgres MCP Pro is an open-source MCP server that gives AI agents access to a PostgreSQL database, with schema browsing, safe SQL execution, EXPLAIN plans, index recommendations and database health checks.
- [Redis](https://cookiesforai.app/mcp/redis): The Redis MCP server gives AI agents natural-language access to a Redis database: strings, hashes, lists, sets, sorted sets, streams, JSON documents, pub/sub and vector search indexes.

