---
title: "MongoDB: setup for Claude, Cursor, Codex · DotsAgent"
description: "Query and administer MongoDB databases and Atlas clusters, using a connection string or an Atlas service account. Set up MongoDB in 13 MCP clients."
url: https://dotsagent.io/mcp/servers/mongodb
---

Data · MongoDB

# Set up MongoDB

Query and administer MongoDB databases and Atlas clusters, using a connection string or an Atlas service account.

- **Publisher**: MongoDB Official
- **Run locally**: `npx -y mongodb-mcp-server@latest --readOnly`
- **Transports**: stdio, streamable-http
- **Authentication**: A connection string, an Atlas service account with client ID and secret, or both.
- **Environment**: `MDB_MCP_CONNECTION_STRING``MDB_MCP_API_CLIENT_ID``MDB_MCP_API_CLIENT_SECRET`
- **What it can touch**: Read and write; --readOnly limits it to reads.
- **Licence**: Apache-2.0
- **Source**: [github.com/mongodb-js/mongodb-mcp-server](https://github.com/mongodb-js/mongodb-mcp-server)
- **Status**: Active

## Install

This server runs on your machine as a child process of the client. You need the runtime its command uses, such as Node.js for npx, uv for uvx or Docker, plus any variables listed under Environment.

### Claude Code

`shell`

```
claude mcp add --scope project --env MDB_MCP_CONNECTION_STRING='<MDB_MCP_CONNECTION_STRING>' --env MDB_MCP_API_CLIENT_ID='<MDB_MCP_API_CLIENT_ID>' --env MDB_MCP_API_CLIENT_SECRET='<MDB_MCP_API_CLIENT_SECRET>' mongodb -- npx -y mongodb-mcp-server@latest --readOnly
```

### Cursor

`.cursor/mcp.json`

```
{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "${env:MDB_MCP_CONNECTION_STRING}",
        "MDB_MCP_API_CLIENT_ID": "${env:MDB_MCP_API_CLIENT_ID}",
        "MDB_MCP_API_CLIENT_SECRET": "${env:MDB_MCP_API_CLIENT_SECRET}"
      }
    }
  }
}
```

### Codex

`~/.codex/config.toml`

```
[mcp_servers.mongodb]
command = "npx"
args = ["-y", "mongodb-mcp-server@latest", "--readOnly"]
env_vars = ["MDB_MCP_CONNECTION_STRING", "MDB_MCP_API_CLIENT_ID", "MDB_MCP_API_CLIENT_SECRET"]
```

[Config for other clients →](https://dotsagent.io/mcp/config#add=mongodb)

The generated command keeps --readOnly; drop it only if the agent should write.

## Other servers in data

- [Airtable](https://dotsagent.io/mcp/servers/airtable): Query, create and update records in Airtable bases, limited to the bases you authorise.

- [BigQuery](https://dotsagent.io/mcp/servers/google-bigquery): Google-hosted endpoint to explore BigQuery datasets and run SQL. Cloud SQL and Spanner have their own.

- [MCP Toolbox for Databases](https://dotsagent.io/mcp/servers/mcp-toolbox-databases): One server with prebuilt tool sets for Postgres, MySQL, BigQuery, AlloyDB, Spanner and other databases.

- [Supabase](https://dotsagent.io/mcp/servers/supabase): Manage Supabase projects from an agent: run SQL, apply migrations, read logs and deploy Edge Functions.

- [Neon](https://dotsagent.io/mcp/servers/neon): Create Neon Postgres projects and branches, run SQL and do branch-based migrations. Meant for development use.

- [Redis](https://dotsagent.io/mcp/servers/redis): Lets an agent work with Redis data structures, search and vector indexes in plain language.

## Sources

1. [github.com](https://github.com/mongodb-js/mongodb-mcp-server)/mongodb-js/mongodb-mcp-server

Independent reference for people who build AI agents. Not affiliated with any vendor named here.

© 2026 DotsAgent · Facts checked October 1, 2026
