MongoDB MCP Server

v1.10.0Databasesstable

This repository implements an MCP (Model Context Protocol) server that connects to a MongoDB database and exposes operations for managing databases, collections, documents, indexes, and bulk operations. It uses Node.js, TypeScript, and the MCP SDK, e

mcpmcp-servermongodbmongodb-atlasmongodb-database
Share:
1,029
Stars
0
Downloads
0
Weekly
0/5

What is MongoDB MCP Server?

MongoDB MCP Server is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to this repository implements an mcp (model context protocol) server that connects to a mongodb database and exposes operations for managing databases, collections, documents, indexes, and bulk operation...

This repository implements an MCP (Model Context Protocol) server that connects to a MongoDB database and exposes operations for managing databases, collections, documents, indexes, and bulk operations. It uses Node.js, TypeScript, and the MCP SDK, e

This server falls under the Databases category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • connect
  • list-collections
  • list-databases
  • collection-indexes
  • create-index

Use Cases

Manage MongoDB databases through natural language
CRUD operations and index management for AI agents
mongodb-js

Maintainer

LicenseApache-2.0
Languagetypescript
Versionv1.10.0
UpdatedMay 21, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y mongodb-mcp-server

Manual Installation

npx -y mongodb-mcp-server

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use MongoDB MCP Server

The MongoDB MCP Server is the official MCP integration maintained by MongoDB, Inc. that gives AI assistants direct access to MongoDB databases and MongoDB Atlas clusters through natural language. It exposes a comprehensive set of tools covering CRUD operations, aggregation pipelines, index management, schema inference, Atlas cluster administration, database user management, IP access lists, and Performance Advisor recommendations. Development teams use it to let Claude and other MCP clients query, update, and manage MongoDB data without writing driver code.

Prerequisites

  • Node.js v22.13.0 or later
  • A running MongoDB instance (local, Docker, or cloud) with a connection string, OR MongoDB Atlas account credentials
  • For Atlas management features: a MongoDB Atlas service account with `MDB_MCP_API_CLIENT_ID` and `MDB_MCP_API_CLIENT_SECRET`
  • An MCP-compatible client such as Claude Desktop, VS Code, or Cursor
1

Verify Node.js version

The server requires Node.js v22.13.0 or later. Check your version and upgrade if needed.

node --version
2

Test the server with npx

Run the server directly to confirm it starts. In read-only mode it is safe to run against any database without risk of modifications.

npx -y mongodb-mcp-server@latest --readOnly
3

Configure Claude Desktop

Add the MongoDB MCP server to your Claude Desktop configuration file. Store your connection string as an environment variable rather than hardcoding it.

4

Restart Claude Desktop

Restart Claude Desktop to load the new server configuration. Verify that the MongoDB tools appear in the tool list.

5

Connect to your database

Ask Claude to connect to your MongoDB instance. The server also supports switching connections mid-session.

MongoDB MCP Server Examples

Client configuration

Claude Desktop configuration for the official MongoDB MCP server using a local connection string. For Atlas API access, add `MDB_MCP_API_CLIENT_ID` and `MDB_MCP_API_CLIENT_SECRET` to the env block.

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

Prompts to try

Sample prompts for using the MongoDB MCP server with Claude Desktop.

- "List all databases and the collections in the 'ecommerce' database."
- "Find the 10 most recent orders in the orders collection where status is 'pending'."
- "What indexes exist on the users collection? Are there any missing indexes for the queries I'm running?"
- "Insert a new product document into the products collection with these fields: [name, price, category]."
- "Run an aggregation to calculate total revenue per product category for the last 30 days."
- "Show me the schema of the events collection by sampling 100 documents."

Troubleshooting MongoDB MCP Server

Connection refused when using `mongodb://localhost:27017`

Verify MongoDB is running locally with `mongosh --eval 'db.runCommand({ping:1})'`. If using Docker, ensure the container port is mapped: `docker run -p 27017:27017 mongo`. For Atlas, use the full `mongodb+srv://` connection string from the Atlas console.

Atlas API operations return 401 Unauthorized

Ensure `MDB_MCP_API_CLIENT_ID` and `MDB_MCP_API_CLIENT_SECRET` are set to a valid Atlas service account. The service account must be assigned at the organization or project level with the minimum required role (e.g., `Project Read Only` for read operations). Generate new credentials in Atlas under Access Manager → Service Accounts.

Write operations are rejected even though `--readOnly` is not set

Check whether `MDB_MCP_READ_ONLY=true` is set in the environment. Remove that variable or set it to `false` to allow write operations. Also verify the MongoDB user in the connection string has write permissions on the target database.

Frequently Asked Questions about MongoDB MCP Server

What is MongoDB MCP Server?

MongoDB MCP Server is a Model Context Protocol (MCP) server that this repository implements an mcp (model context protocol) server that connects to a mongodb database and exposes operations for managing databases, collections, documents, indexes, and bulk operations. it uses node.js, typescript, and the mcp sdk, e It connects AI assistants to external tools and data sources through a standardized interface.

How do I install MongoDB MCP Server?

Install via npm with the command: npx -y mongodb-mcp-server. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).

Which AI clients work with MongoDB MCP Server?

MongoDB MCP Server works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is MongoDB MCP Server free to use?

Yes, MongoDB MCP Server is open source and available under the Apache-2.0 license. You can use it freely in both personal and commercial projects.

Browse More Databases MCP Servers

Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

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

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use MongoDB MCP Server?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides