Skip to content

MCP server

MongoDB MCP server

MongoDB's official MCP server lets AI query collections, run aggregations and manage Atlas clusters, with a read-only flag for safe use.

At a glance

Maintained by
MongoDB
Tools exposed
10 listed below
Reviewed
September 24, 2026

Why it matters

What it does and why it matters

MongoDB stores data as flexible documents, which is common in modern web and mobile apps. Its official MCP server lets an AI assistant find documents, count them, run aggregation pipelines and describe a collection's schema. It can also list and manage Atlas clusters when given Atlas credentials.

For business teams, this turns questions about app data into plain-English requests. For developers, it speeds up exploring data and writing aggregation pipelines, which are powerful but hard to write by hand.

The server has a read-only flag that limits it to read, connect and metadata tools. We use that flag for everything except development work. Atlas management tools use a service account, so keep those credentials separate from data access and give them the smallest role that works.

Use cases

Best business use cases

App analytics

Ask how many users signed up this week, by source.

Aggregation help

Have the assistant write and run aggregation pipelines.

Schema discovery

Understand what fields each collection holds.

Atlas overview

List clusters and their settings across projects.

Support lookups

Find a user's records during a support case.

Tools

Available tools

Tool names as published by the maintainer at review time. Versions change, so check the repository for the current list.

Read and write: Read and write for databases and Atlas; the --readOnly flag limits it to read, connect and metadata tools.

  • find

    Runs a query against a collection.

  • aggregate

    Runs an aggregation pipeline.

  • count

    Counts documents that match a filter.

  • insert-many

    Inserts many documents into a collection.

  • update-many

    Updates all documents that match a filter.

  • delete-many

    Deletes documents that match a filter.

  • list-databases

    Lists databases on the connection.

  • list-collections

    Lists collections in a database.

  • collection-schema

    Describes the schema of a collection.

  • atlas-list-clusters

    Lists Atlas clusters in a project.

Workflows

Example workflows

Weekly signup report

  1. 1

    Start the server with the read-only flag.

  2. 2

    Ask for signups by source for the last four weeks.

  3. 3

    The assistant builds an aggregation pipeline.

  4. 4

    It runs it and presents a table.

  5. 5

    You ask for the trend compared with last month.

Understand a new collection

  1. 1

    A developer joins a project.

  2. 2

    They ask the assistant to describe each collection.

  3. 3

    It samples documents and reports the schema.

  4. 4

    It highlights fields that vary between documents.

  5. 5

    The developer writes queries with that knowledge.

Prompts

Example prompts

  • “How many new users signed up each week this month, grouped by signup source?”

  • “Describe the schema of the orders collection and any fields that vary.”

  • “List our Atlas clusters and their tiers.”

Setup

Installation and configuration

Examples for Claude Desktop and Claude Code. Replace the placeholder values with your own keys, and store secrets outside version control.

Claude Desktop: claude_desktop_config.json

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

Claude Code: terminal

claude mcp add mongodb -e MDB_MCP_CONNECTION_STRING="mongodb://localhost:27017/myDatabase" -- npx -y mongodb-mcp-server@latest --readOnly
  • Local server: stdio. npm: mongodb-mcp-server.
  • Needs: MDB_MCP_CONNECTION_STRING (database connection string); or for Atlas: MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET (service account).

Security

Security considerations

  • Least privilege

    Create a dedicated database user that can read only the tables the assistant needs.

  • Use a replica

    Point the server at a read replica or copy, not the primary production database.

  • Log every query

    Keep a log of the queries the assistant runs, and review it in the first weeks.

  • Watch for sensitive data

    Use the read-only flag and a database user limited to the collections the assistant needs.

Related servers

Servers that pair well with it

PostgreSQL

Lets AI assistants explore a PostgreSQL database, run SQL in a restricted read-only mode and check query performance and database health.

Redis

Redis's official MCP server lets AI read and write Redis data structures, search vector indexes and inspect server information.

Supabase

Supabase's official hosted MCP server lets AI work with your Supabase projects: tables, SQL, migrations, edge functions, branches and docs.

Keep exploring

FAQ

Questions people ask us

Have a question that is not here? Ask us directly.

Start a project

Want this connected to your own systems? We build AI workflows with MCP.

Send a short brief. We reply with questions, a suggested plan and an estimate you can compare with other offers.

Your privacy choices

We use necessary storage to run this site. With your permission we also use Google Analytics to see which pages help people, and load maps from Google. You can change this at any time. Read the cookie policy.