Official Data & Analytics

MongoDB

Query MongoDB collections and aggregate pipelines.

Works with: Claude DesktopCursor

Official server · details last checked

Quick install
npx -y @mongodb/mcp-server

How to install the MongoDB MCP server

Add this to your Claude Desktop MCP configuration:

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "@mongodb/mcp-server"
      ]
    }
  }
}

Add this to your Cursor MCP configuration:

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "@mongodb/mcp-server"
      ]
    }
  }
}

Built by ContextBoltThis directory is built by ContextBolt: MCP-native memory and SEO tools that run alongside MongoDB in the same client.

Explore ContextBolt

The MongoDB MCP server gives an agent access to collections, documents and the aggregation framework. Mongo’s flexibility is its selling point and its problem: without a fixed schema, working out what is actually in a collection is a job in itself, and that is precisely what this helps with.

What it actually does

The server connects with a standard connection string and exposes the database as tools. The agent can list collections, sample documents to infer their shape, run finds with filters, and build aggregation pipelines. Schema inference matters more here than in a relational database, because there is no authoritative definition to read; the shape has to be derived from the data.

Practical patterns:

  • ‘What fields appear in this collection, and how consistently?’
  • ‘Aggregate orders by month and customer segment for the last year.’
  • ‘Find documents where the address object is missing a postcode.‘

Why use it

Aggregation pipelines are the clearest win. The syntax is verbose, the stages compose in ways that are easy to get subtly wrong, and the feedback loop is slow because a malformed pipeline often returns an empty result rather than an error. Describing the output you want and letting the agent assemble the stages removes most of that friction.

Gotchas

Schema inference is inference. On a collection where documents have drifted over several years of shipping, the sampled shape can miss variants that matter, and a query built on that assumption will quietly skip records. Ask what it sampled if the answer looks too clean. Use a read-only user unless you have a specific reason not to, and be careful with finds that return large documents, since a few hundred fat records will fill a context window fast.

Built by ContextBolt

This directory is built by ContextBolt

We build MCP-native tools that give your AI the context it cannot reach on its own. Bookmarks turns your saved posts into agent-queryable memory. SEO puts live keyword and ranking data inside Claude. Both run alongside MongoDB in the same client.

Explore the products →

MongoDB MCP server: FAQs

How does it handle a schemaless collection?

It samples documents to infer the shape. That works well on consistent collections and less well where documents have drifted apart over years.

Can it write or delete?

It exposes write operations subject to your connection's permissions. A read-only user is the safer default.

Is it good at aggregation pipelines?

This is the strongest use. Mongo's aggregation syntax is verbose and easy to get subtly wrong, and describing the result you want is much faster.

Does it work with Atlas?

Yes, it connects with a standard connection string, so a hosted Atlas cluster works the same as a local instance.