What Is MongoDB MCP Server?

MongoDB MCP Server connects Claude to MongoDB databases, enabling you to run queries, inspect indexes, and analyze documents directly from your Claude session. It is maintained by kiliczsh as an open-source project.


Quick Facts

FieldValue
Packagemcp-mongodb
Installnpx mcp-mongodb
Compatible withClaude Code, Claude Desktop
Statusactive
GitHubhttps://github.com/kiliczsh/mcp-mongo-server

What You Can Do With It

  • Collection queries: Ask Claude to filter, sort, and retrieve documents from any accessible collection.
  • Aggregation pipelines: Build and execute multi-stage aggregation pipelines without leaving your Claude session.
  • Index analysis: Inspect existing indexes on a collection to identify coverage gaps or redundant indexes.
  • Schema inspection: Sample documents to understand the shape of a collection’s data, including field types and nesting.

How to Set It Up

Prerequisites: Node.js 18+ and a reachable MongoDB instance (local or remote).

Step 1 — Test the package runs:

npx mcp-mongodb
**Step 2 — Configure Claude Desktop**

Add the server to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or the equivalent path on your OS:

```json
{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": ["mcp-mongodb"],
      "env": {
        "MONGODB_URI": "mongodb://localhost:27017/your-database"
      }
    }
  }
}

Replace mongodb://localhost:27017/your-database with your actual connection string.

Step 3 — Configure Claude Code

Add the same block to .claude/mcp.json at the root of your project:

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": ["mcp-mongodb"],
      "env": {
        "MONGODB_URI": "mongodb+srv://user:password@cluster.mongodb.net/your-database"
      }
    }
  }
}

Restart Claude after saving the config. The server should appear as an available tool in your session.


Works Best With

MongoDB MCP Server is confirmed compatible with Claude Code and Claude Desktop. Both clients support the stdio transport that npx mcp-mongodb uses. Claude Code is particularly useful here if you are working in a codebase that already connects to MongoDB — you can inspect the live database alongside your source files in the same session.


Known Limitations

  • Authentication: Connection strings with passwords are passed as plain environment variables. Avoid committing .claude/mcp.json to version control if it contains credentials. Use a secrets manager or environment variable injection where possible.
  • Read/write scope: Verify what permissions the MongoDB user in your connection string has. The server will execute whatever operations Claude requests, so a read-only user is advisable for production databases.
  • No built-in rate limiting: The server does not throttle queries. Large aggregation pipelines or collection scans on unindexed fields can place real load on your database.
  • Atlas compatibility: If connecting to MongoDB Atlas, ensure your IP is allowlisted in the Atlas network access settings.
  • Driver version drift: Since the package runs via npx, it pulls the latest published version each time unless you pin a version with npx mcp-mongodb@x.y.z.

Community Resources

This article contains affiliate links. We may earn a commission at no extra cost to you. Learn more.

Share: X