# Mongodb MCP Server

> Mongodb MCP Server is an open-source MCP server for databases. Open-source MCP server letting AI assistants query and manage MongoDB and Atlas clusters. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, API, self-hosted, vscode, macOS, Linux, Windows
- **Repository:** https://github.com/mongodb-js/mongodb-mcp-server
- **MCP Registry name:** io.github.mongodb-js/mongodb-mcp-server
- **Categories:** [databases](https://ai-powered.com/categories/databases)
- **Listing updated:** 2026-11-18

## About

The README describes this as a Model Context Protocol server that gives AI clients access to MongoDB databases and MongoDB Atlas. It runs locally over stdio and is distributed as an npm package, with Docker images and one-click install links for several editors. Read-only mode is recommended in the setup examples, and write operations can be enabled by removing that flag.

The server exposes database tools for querying, aggregation, indexes, schema inspection, and data changes, plus a separate set of Atlas tools for managing projects, clusters, users, and access lists when Atlas API credentials are configured. Destructive operations such as dropping collections or deleting many documents can be set to require user confirmation. Connections can be a single connection string or several named ones.

It suits developers and data teams who want an assistant to explore or administer MongoDB deployments from an editor or agent client. The README also points to a separate hosted Atlas-managed MCP server as the recommended route for Atlas users.

## Features

- **Database query tools:** Run find, aggregate, count, and export operations against collections from an MCP client.
- **Schema and index inspection:** Describe collection schemas, list indexes, and create or drop indexes.
- **Atlas management tools:** Create and inspect Atlas projects, clusters, database users, and IP access lists with service account credentials.
- **Read-only mode:** A --readOnly flag limits the server to non-mutating access, which the setup examples enable by default.
- **Confirmation for destructive tools:** Selected tools such as drop-database and delete-many can require user approval before running.
- **Multiple named connections:** Connection strings can be keyed by name so one server reaches several deployments.

## Good for

- Asking an AI assistant to explore collections and sample documents during development
- Checking index usage and performance advisor suggestions for slow queries
- Provisioning a test Atlas cluster or sample dataset from an editor
- Letting an agent run aggregations against analytics data in read-only mode

## Install

### Claude Code (Terminal)

```sh
claude mcp add mongodb-mcp-server --env MDB_MCP_API_CLIENT_ID='<MDB_MCP_API_CLIENT_ID>' --env MDB_MCP_API_CLIENT_SECRET='<MDB_MCP_API_CLIENT_SECRET>' --env MDB_MCP_CONNECTION_STRING='<MDB_MCP_CONNECTION_STRING>' --env MDB_MCP_CONNECTION_STRINGS='<MDB_MCP_CONNECTION_STRINGS>' --env MDB_MCP_VOYAGE_API_KEY='<MDB_MCP_VOYAGE_API_KEY>' -- npx -y mongodb-mcp-server
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server"
      ],
      "env": {
        "MDB_MCP_API_CLIENT_ID": "<MDB_MCP_API_CLIENT_ID>",
        "MDB_MCP_API_CLIENT_SECRET": "<MDB_MCP_API_CLIENT_SECRET>",
        "MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>",
        "MDB_MCP_CONNECTION_STRINGS": "<MDB_MCP_CONNECTION_STRINGS>",
        "MDB_MCP_VOYAGE_API_KEY": "<MDB_MCP_VOYAGE_API_KEY>"
      }
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server"
      ],
      "env": {
        "MDB_MCP_API_CLIENT_ID": "<MDB_MCP_API_CLIENT_ID>",
        "MDB_MCP_API_CLIENT_SECRET": "<MDB_MCP_API_CLIENT_SECRET>",
        "MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>",
        "MDB_MCP_CONNECTION_STRINGS": "<MDB_MCP_CONNECTION_STRINGS>",
        "MDB_MCP_VOYAGE_API_KEY": "<MDB_MCP_VOYAGE_API_KEY>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "mongodb-mcp-server": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server"
      ],
      "env": {
        "MDB_MCP_API_CLIENT_ID": "<MDB_MCP_API_CLIENT_ID>",
        "MDB_MCP_API_CLIENT_SECRET": "<MDB_MCP_API_CLIENT_SECRET>",
        "MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>",
        "MDB_MCP_CONNECTION_STRINGS": "<MDB_MCP_CONNECTION_STRINGS>",
        "MDB_MCP_VOYAGE_API_KEY": "<MDB_MCP_VOYAGE_API_KEY>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server"
      ],
      "env": {
        "MDB_MCP_API_CLIENT_ID": "<MDB_MCP_API_CLIENT_ID>",
        "MDB_MCP_API_CLIENT_SECRET": "<MDB_MCP_API_CLIENT_SECRET>",
        "MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>",
        "MDB_MCP_CONNECTION_STRINGS": "<MDB_MCP_CONNECTION_STRINGS>",
        "MDB_MCP_VOYAGE_API_KEY": "<MDB_MCP_VOYAGE_API_KEY>"
      }
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server"
      ],
      "env": {
        "MDB_MCP_API_CLIENT_ID": "<MDB_MCP_API_CLIENT_ID>",
        "MDB_MCP_API_CLIENT_SECRET": "<MDB_MCP_API_CLIENT_SECRET>",
        "MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>",
        "MDB_MCP_CONNECTION_STRINGS": "<MDB_MCP_CONNECTION_STRINGS>",
        "MDB_MCP_VOYAGE_API_KEY": "<MDB_MCP_VOYAGE_API_KEY>"
      }
    }
  }
}
```

## Tools

- `aggregate`: Run an aggregation against a MongoDB collection
- `find`: Run a find query against a MongoDB collection
- `count`: Gets the number of documents in a MongoDB collection
- `collection-schema`: Describe the schema for a collection
- `collection-indexes`: Describe the indexes for a collection
- `create-index`: Create an index for a collection
- `delete-many`: Removes all documents that match the filter from a MongoDB collection
- `atlas-list-clusters`: List MongoDB Atlas clusters
- `atlas-create-free-cluster`: Create a free MongoDB Atlas cluster

## FAQ

### Does it need a running MongoDB instance?

It connects to a MongoDB connection string for self-managed or Atlas deployments, or to Atlas through API credentials. The README says the connection string can point to a local instance or an Atlas cluster.

### Can it run without write access?

Yes. The setup examples include --readOnly, and the README says to remove that flag only if write operations are needed.

### What is required to use the Atlas tools?

Atlas tools need Atlas Service Account API credentials, with client ID and secret set as environment variables.

### What Node version is required?

The README says at least Node.js v22.13.0 and notes that Node 20 support is deprecated.

### Is Mongodb MCP Server free?

Yes. Mongodb MCP Server is open source, so you can use and self-host it for free.

### How do I add Mongodb MCP Server to Claude Code?

Run this command in your terminal: claude mcp add mongodb-mcp-server --env MDB_MCP_API_CLIENT_ID='<MDB_MCP_API_CLIENT_ID>' --env MDB_MCP_API_CLIENT_SECRET='<MDB_MCP_API_CLIENT_SECRET>' --env MDB_MCP_CONNECTION_STRING='<MDB_MCP_CONNECTION_STRING>' --env MDB_MCP_CONNECTION_STRINGS='<MDB_MCP_CONNECTION_STRINGS>' --env MDB_MCP_VOYAGE_API_KEY='<MDB_MCP_VOYAGE_API_KEY>' -- npx -y mongodb-mcp-server

### What are the best alternatives to Mongodb MCP Server?

The closest alternatives to Mongodb MCP Server are MCP Toolbox for Databases, Db Conn MCP, Mysql, MCP Server Couchbase and Metabase MCP (headless).

## Where this comes from

- Description: written from the project's README and its MCP Registry entry.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [MCP Toolbox for Databases](https://ai-powered.com/mcp/mcp-toolbox-for-databases-2): MCP Toolbox for Databases is an open-source MCP server for databases.
- [Db Conn MCP](https://ai-powered.com/mcp/db-conn-mcp): Db Conn MCP is an MCP server for databases.
- [Mysql](https://ai-powered.com/mcp/mysql): Mysql is an open-source MCP server for databases.
- [MCP Server Couchbase](https://ai-powered.com/mcp/mcp-server-couchbase): MCP Server Couchbase is an open-source MCP server for databases.
- [Metabase MCP (headless)](https://ai-powered.com/mcp/metabase-mcp-headless): Metabase MCP (headless) is an open-source MCP server for browser automation.
- [XenMCP](https://ai-powered.com/mcp/xenmcp): XenMCP is a free MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/mongodb-mcp-server
