MongoDB

MongoDB

Official

Query and inspect MongoDB collections from Claude, Cursor, and VS Code.

Score 90(?)MongoDBApache-2.01.1kVerified Top MCPs for Databases →

Quick answer

What it does

Connects to a MongoDB deployment and exposes database/collection enumeration, schema inspection, find queries, and aggregation pipelines to AI models.

Best for

  • Collection schema exploration
  • Aggregation pipeline drafting
  • Document inspection
  • Reporting queries

Not for

  • Transactional multi-document writes
  • Long-running Change Streams

Source: top-mcps.com/mcp/mongodb — verified Nov 2026

Setup recipe

Pick your client, then follow the three steps.

  1. 1

    Install

    claude_desktop_config.json
    {
      "mcpServers": {
        "mongodb": {
          "command": "npx",
          "args": [
            "-y",
            "mongodb-mcp-server",
            "--readOnly"
          ],
          "env": {
            "MDB_MCP_CONNECTION_STRING": "${MDB_MCP_CONNECTION_STRING}"
          }
        }
      }
    }

    Paste under mcpServers. Fully quit and reopen Claude after editing.

    CLI or .mcp.json
    # export MDB_MCP_CONNECTION_STRING=mongodb+srv://user:pass@cluster.mongodb.net
    claude mcp add mongodb -- npx -y mongodb-mcp-server --readOnly

    Run from your repo. Commit .mcp.json to share with your team.

    .cursor/mcp.json
    {
      "mcpServers": {
        "mongodb": {
          "command": "npx",
          "args": [
            "-y",
            "mongodb-mcp-server",
            "--readOnly"
          ],
          "env": {
            "MDB_MCP_CONNECTION_STRING": "${MDB_MCP_CONNECTION_STRING}"
          }
        }
      }
    }

    Global path: ~/.cursor/mcp.json. Reload window after editing.

    .vscode/mcp.json
    {
      "servers": {
        "mongodb": {
          "command": "npx",
          "args": [
            "-y",
            "mongodb-mcp-server",
            "--readOnly"
          ],
          "env": {
            "MDB_MCP_CONNECTION_STRING": "${MDB_MCP_CONNECTION_STRING}"
          }
        }
      }
    }

    VS Code uses the "servers" key (not "mcpServers").

    ~/.codeium/windsurf/mcp_config.json
    {
      "mcpServers": {
        "mongodb": {
          "command": "npx",
          "args": [
            "-y",
            "mongodb-mcp-server",
            "--readOnly"
          ],
          "env": {
            "MDB_MCP_CONNECTION_STRING": "${MDB_MCP_CONNECTION_STRING}"
          }
        }
      }
    }

    Open via Cascade → hammer icon → Configure.

    cline_mcp_settings.json
    {
      "mcpServers": {
        "mongodb": {
          "command": "npx",
          "args": [
            "-y",
            "mongodb-mcp-server",
            "--readOnly"
          ],
          "env": {
            "MDB_MCP_CONNECTION_STRING": "${MDB_MCP_CONNECTION_STRING}"
          }
        }
      }
    }

    Open via the Cline sidebar → MCP Servers → Edit.

    ~/.continue/config.json
    {
      "experimental": {
        "modelContextProtocolServers": [
          {
            "transport": {
              "type": "stdio",
              "command": "npx",
              "args": [
                "-y",
                "mongodb-mcp-server",
                "--readOnly"
              ],
              "env": {
                "MDB_MCP_CONNECTION_STRING": "${MDB_MCP_CONNECTION_STRING}"
              }
            }
          }
        ]
      }
    }

    Continue uses modelContextProtocolServers with a transport block.

    ~/.codex/config.toml
    # ~/.codex/config.toml
    [mcp_servers.mongodb]
    command = "npx"
    args = [
      "-y",
      "mongodb-mcp-server",
      "--readOnly",
    ]
    env = { MDB_MCP_CONNECTION_STRING = "${MDB_MCP_CONNECTION_STRING}" }

    Codex uses TOML. Each server is a [mcp_servers.<name>] subtable.

    ~/.config/zed/settings.json
    {
      "context_servers": {
        "mongodb": {
          "command": {
            "path": "npx",
            "args": [
              "-y",
              "mongodb-mcp-server",
              "--readOnly"
            ]
          },
          "env": {
            "MDB_MCP_CONNECTION_STRING": "${MDB_MCP_CONNECTION_STRING}"
          }
        }
      }
    }

    Zed calls them "context_servers". Settings live-reload on save.

    ChatGPT → Plugins

    MongoDB doesn't ship a hosted HTTPS endpoint today. ChatGPT supports remote MCP servers only — to use this server in ChatGPT you'll need to deploy it to a public HTTPS URL first (e.g. via Cloudflare Workers or Vercel) or wait for an official remote build.

  2. 2

    Set required secrets

    Set MDB_MCP_CONNECTION_STRING in your shell environment before launching your MCP client.

  3. 3

    Try a minimum working prompt

    Minimum working prompt pending verification. Try any prompt from the MCP’s README once installed.

Tools & permissions

Showing 12 of 53 tools the server reported. The rest are real, just not listed here.

ToolDescriptionArgsSide effects
list-databasesList all databases for a MongoDB connection.—Read
list-collectionsList all collections for a given database.—Read
collection-schemaDescribe a collection's schema from a sample of documents (50 by default).—Read
collection-indexesDescribe the indexes for a collection.—Read
findRun a find query against a collection.—Read
countCount the documents in a collection, with an optional filter.—Read
aggregateRun an aggregation pipeline; asks for confirmation first when the pipeline contains `$out` or `$merge`.—Read
explainReturn the winning query plan and its execution statistics.—Read
insert-manyInsert an array of documents. Disabled by `--readOnly`.—Write
update-manyUpdate every document that matches a filter. Disabled by `--readOnly`.—Write
delete-manyDelete every document that matches a filter; confirmation required by default.—Write
drop-databaseDrop a database and its data files; confirmation required by default.—Write

Security & scope

Access scope
Read + write
Sandbox
Connects through the MongoDB driver to the connection string in `MDB_MCP_CONNECTION_STRING`. Writes are on by default; `--readOnly` disables the create, update and delete tools at the MCP layer. Pair it with a database user scoped to the smallest namespace the workflow needs.
Gotchas
  • Read-only is opt-in. Without `--readOnly` the agent can call `insert-many`, `update-many`, `delete-many` and `drop-database`. Read-only is enforced at the tool level, not the MongoDB role, so pair it with a read-only database user.
  • The confirmation on drop and delete tools uses MCP elicitation. A client that does not support elicitation cannot show the prompt, so do not count on it as the only gate.
  • Schema inference samples N documents; rare fields may be missing from the inferred schema.
  • The `atlas-*` tools need an Atlas service account with its own permissions — they can create clusters and database users, so give that account the narrowest Atlas role that works.

Agent prompt pack

— copy into Claude, Cursor, or ChatGPT.
Paste into Claude, Cursor, or ChatGPT. Edit the [brackets] before sending.
Recommend the best MCP servers for [task: e.g. databases work] in [client: Claude].

Constraints:
- Prefer tools that are [official | open-source | read-only] — pick what matters for my use case.
- Exclude MCPs that require [e.g. a paid plan, OAuth-only flows, remote-only transport].
- Return at most 3 picks, ranked.

For each pick include:
1. One-sentence rationale.
2. The ready-to-paste install snippet for my client.
3. Any required secrets I need to create before installing.

Cross-check the top-mcps.com listing: https://top-mcps.com/top-mcps-for-databases
Compare MongoDB against a real alternative. Swap the second MCP in [brackets] if you want a different match.
Compare MongoDB MCP vs [Postgres MCP Pro MCP] for the following job: [describe the job, e.g. "let an agent create GitHub issues on bug triage"].

Judge them on:
- Setup time and complexity (what a new user hits first).
- Auth model (none / API key / OAuth 2.1) and credential risk.
- Transport (stdio / Streamable HTTP / SSE) and where the server runs.
- Required secrets and the blast radius if they leak.
- Operational risk in an unattended agent loop.
- Which one is "good enough" for a weekend prototype vs. production.

End with one sentence: which should I pick for my scenario, which is: [my scenario].

References:
- https://top-mcps.com/mcp/mongodb
- top-mcps.com listing for Postgres MCP Pro
Asks the agent to install and verify. Works inside Claude Code, Cursor Agent, Codex CLI.
Install the MongoDB MCP server for my [client: Claude] at the default config path for that client.

Use the exact install snippet published at https://top-mcps.com/mcp/mongodb (fetch https://top-mcps.com/mcp/mongodb.json for the canonical server.json if you can read URLs).

Before finishing:
1. Create the required secrets (MDB_MCP_CONNECTION_STRING) and put them in the appropriate env block — do not hard-code them.
2. Restart or reload the client so it picks up the new server.
3. Verify the server is connected (green / running state) and at least one tool is listed.
4. If anything fails, read the client's MCP logs and report the exact error — do not silently retry.

Confirm when done and list the tools the server now exposes.

Frequently asked questions

What changed

— 5 updates tracked.
  1. Entry re-read against v3.1.0: tool names are hyphenated (`list-databases`, not `list_databases`), writes are enabled unless `--readOnly` is passed, the env vars are `MDB_MCP_CONNECTION_STRING` and `MDB_MCP_READ_ONLY`, and the `--database` option this page described does not exist.

  2. v3.1.0 released; since v3 the tools ship in separate @mongodb-js/mcp-tools-* packages.

  3. v2.1.0 released

  4. mongodb-atlas-mcp-remote/v1.0.0 released

  5. v2.0.1-alpha.5 released

More Databases MCPs

Other tools in the same category worth evaluating.

Postgres MCP ProPRO

Production-grade Postgres MCP with index advice, EXPLAIN, and health checks.

database, sql, postgres, performance
5 minMedium
SQLite

Local SQLite database access with full read/write support.

database, sqlite, local, storage
2 minLow

Full Supabase access: database, auth, storage, and edge functions.

supabase, database, backend, postgres
5 minLow

Compared with MongoDB

Side-by-side breakdowns for the choices people most often weigh against this MCP.

Exploring Top MCPs for Databases? See all Databases MCPs →