MongoDB MCP Server

by @mongodb-js

Mongo Db MCP Server

MongoDB MCP Server connects AI clients to MongoDB databases and Atlas. Its tools cover queries, schema inspection, database changes, and MongoDB knowledge searches, with read-only launch examples for safer exploration.

Databases1,143nodeApache-2.0

Server facts

MongoDB MCP Server

GitHub stars

1,143

Last commit

Oct 16, 2026

Runtime

node

License

Apache-2.0

Project

License
Apache-2.0
Category
Databases

Tech

Runtime
node
Transports
stdio
Remote access
No

Activity

GitHub stars
1,143
Last commit
Data as of

Tags

  • Database Queries
  • Mongodb
  • Mongodb Atlas
  • Schema Inspection

Overview

MongoDB MCP Server exposes database and Atlas interactions to MCP-compatible assistants. A connection string can target either a local MongoDB instance or an Atlas cluster, while Atlas-specific tools require service-account credentials. The supplied tool inventory spans document queries, aggregation, collection schemas, indexes, storage measurements, execution-plan inspection, and database statistics. It also includes operations that insert, update, delete, rename, or remove database objects. Separate knowledge tools search MongoDB Assistant resources and enumerate their available sources, allowing documentation-oriented questions alongside direct database work.

The README's client examples enable read-only mode, which must be removed when write access is needed. It recommends passing connection strings and credentials through environment variables rather than exposing them in process arguments, and assigning minimal Atlas permissions. A recent Node.js runtime is required: the stated baseline is version 22.13.0, with Node 20 support marked deprecated. Users can launch through npx or Docker; the container option avoids installing Node.js locally. Standard input/output is the default transport, and Streamable HTTP is also documented. The HTTP instructions explicitly warn against direct internet exposure without authentication and other protective measures. Multiple database connections can coexist, with identifiers used by subsequent operations and tools available to list or close active connections.

Install & configure

Requirements

  • Node.js 22.13.0 or later
  • A MongoDB connection string or Atlas service-account credentials
  • An MCP-compatible client
Documented launch / install command
npx -y mongodb-mcp-server@latest --readOnly

This is the README's read-only connection-string setup. Atlas operations instead need MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET. Docker and HTTP alternatives are documented; HTTP needs deployment-level authentication and protection.

Config file · macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

Use Settings → Developer → Edit Config when available. Do not assume a Linux configuration path; check the client documentation for your platform. Remote servers use the app’s connector flow when supported, not the local stdio file shown here. Merge this example with existing settings; do not overwrite unrelated servers.

Claude Desktop configuration
{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
      }
    }
  }
}

Read the Claude Desktop setup guide

Config file · Project: .cursor/mcp.json

User: ~/.cursor/mcp.json

The project path is relative to the workspace root. The tilde denotes your user home directory. Use Cursor’s MCP settings to confirm which configuration and scope your installed version is reading. Merge this example with existing settings; do not overwrite unrelated servers.

Cursor configuration
{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
      }
    }
  }
}

Read the Cursor setup guide

Config file · Workspace: .vscode/mcp.json

For user scope, use the “MCP: Open User Configuration” command if available. Do not guess a user configuration path across operating systems, profiles, containers, or remote workspaces; check the client documentation. Merge this example with existing settings; do not overwrite unrelated servers.

VS Code configuration
{
  "servers": {
    "mongodb-mcp-server": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
      }
    }
  }
}

Read the VS Code setup guide

Config file · macOS/Linux: ~/.codeium/windsurf/mcp_config.json

Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json

Open the MCP configuration through Windsurf’s settings when possible to confirm the active file. Paths can differ in managed or future releases; check the client documentation if this location is not present. Merge this example with existing settings; do not overwrite unrelated servers.

Windsurf configuration
{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
      }
    }
  }
}

Read the Windsurf setup guide

Config file · Project scope: .mcp.json at the repository root

The project file uses mcpServers. For user scope, use claude mcp add --scope user rather than assuming .mcp.json in your home directory is the user configuration. Check the client documentation for managed settings and storage details. Merge this example with existing settings; do not overwrite unrelated servers.

Claude Code configuration
{
  "mcpServers": {
    "mongodb-mcp-server": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest",
        "--readOnly"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
      }
    }
  }
}

Read the Claude Code setup guide

Examples are translated from the published configuration. Supply your own credentials and verify requirements in the upstream README. Remote connectors are shown only where a supported configuration format is known.

Tools

Source: repository tool metadata. Tool descriptions are a documented snapshot, not a live capability check.

ToolWhat it does
aggregate-dbExecute a database-level aggregation pipeline.
aggregateExecute an aggregation pipeline on a collection.
collection-indexesInspect indexes attached to a collection.
collection-schemaInspect a collection's document structure.
collection-storage-sizeReport storage size for a collection.
connectOpen an independent MongoDB connection and return its identifier.
countCount collection documents, optionally constrained by a query.
create-collectionAdd a collection, creating its database if necessary.
create-indexAdd an index to a collection.
db-statsReport usage statistics for one database.
delete-manyDelete collection documents selected by a filter.
disconnectClose a connection; a configured default connection can reopen on later use.
drop-collectionRemove a collection or view together with its indexes.
drop-databaseDelete a database and its associated data files.
drop-indexRemove a specified collection index.
explainInspect execution statistics for the optimizer's selected query plan.
exportSave query or aggregation output in the requested EJSON format.
findSearch documents within a collection.
insert-manyInsert a document array, splitting large payloads into batches when needed.
list-collectionsEnumerate collections belonging to a database.
list-connectionsShow active connection identifiers, including any preconfigured connection.
list-databasesEnumerate databases reachable through a connection.
mongodb-logsRead recent events logged by mongod.
rename-collectionChange a collection's name.
update-manyModify collection documents that satisfy a filter.
list-knowledge-sourcesDiscover sources and filtering options in the MongoDB Assistant knowledge base.
search-knowledgeSearch MongoDB documentation and expert resources with source and version filters.

Use cases

  • Inspect collection schemas and indexes before writing queries.
  • Run document searches and aggregation pipelines from an assistant.
  • Review query plans, database statistics, and recent MongoDB logs.
  • Search MongoDB documentation and curated knowledge sources.

Strengths

  • Covers both local MongoDB and Atlas connections.
  • Read-only examples provide a conservative starting configuration.
  • Offers database operations and MongoDB knowledge lookup in one server.

Limitations

  • Atlas tools require separate service-account credentials.
  • HTTP deployments need additional security controls.
  • Write-enabled tools can delete data and database objects.

MongoDB MCP Server setup notes

  • Check MDB_MCP_CONNECTION_STRING in the MongoDB MCP Server configuration if startup or authentication fails.
  • MongoDB MCP Server's stdio example needs a client that launches local processes.

Frequently asked questions

Yes. A connection string can point to a local MongoDB instance or an Atlas cluster.

Related MCP servers