MongoDB

v0.2.0Databasesstable

A Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.

antrophicclaudeclaude-desktopclinecursor
Share:
278
Stars
0
Downloads
0
Weekly
0/5

What is MongoDB?

MongoDB is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to model context protocol (mcp) server that enables llms to interact directly with mongodb databases. query collections, inspect schemas, and manage data seamlessly through natural language.

A Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.

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

Features

  • A Model Context Protocol (MCP) server that enables LLMs to i

Use Cases

Query MongoDB collections with natural language
Inspect database schemas
Manage data seamlessly
kiliczsh

Maintainer

LicenseMIT License
Languagetypescript
Versionv0.2.0
UpdatedApr 27, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y mongodb

Manual Installation

npx -y mongodb

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

The MongoDB MCP server (mcp-mongo-server) lets LLMs interact directly with MongoDB databases using natural language. It supports schema inference from document samples, full query and aggregation pipeline execution, optional explain plans, write operations (insert, update, index creation), and smart ObjectId handling. Developers and data engineers use it to let Claude explore unfamiliar database schemas, prototype queries, inspect collection statistics, and perform ad-hoc data operations without switching to a separate MongoDB client.

Prerequisites

  • A running MongoDB instance (local, Docker, or MongoDB Atlas)
  • A valid MongoDB connection URI (e.g. mongodb://localhost:27017/dbname or mongodb+srv://...)
  • Node.js 18+ (for npx)
  • Claude Desktop or another MCP-compatible client
1

Confirm your MongoDB connection URI

Gather the connection string for your MongoDB instance. For local instances the default is mongodb://localhost:27017/yourDatabase. For Atlas, copy the connection string from the Atlas dashboard and include your username and password.

2

Test the connection from the command line

Run the server once manually with your URI to verify the connection works before configuring Claude Desktop.

npx -y mcp-mongo-server mongodb://localhost:27017/myDatabase
3

Add the server to Claude Desktop configuration

Add mcp-mongo-server to your Claude Desktop config. Pass the MongoDB URI via the MCP_MONGODB_URI environment variable.

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": ["-y", "mcp-mongo-server"],
      "env": {
        "MCP_MONGODB_URI": "mongodb://localhost:27017/myDatabase"
      }
    }
  }
}
4

Optional: enable read-only mode

Set MCP_MONGODB_READONLY to 'true' or pass --read-only to prevent any write operations. Recommended when connecting to production databases.

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": ["-y", "mcp-mongo-server", "--read-only"],
      "env": {
        "MCP_MONGODB_URI": "mongodb://user:password@host:27017/myDatabase"
      }
    }
  }
}
5

Restart Claude Desktop and explore your database

Restart Claude Desktop. Ask Claude to list collections, describe a schema, or run a query against your database.

MongoDB Examples

Client configuration

Claude Desktop configuration for the MongoDB MCP server using an environment variable for the connection URI.

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": ["-y", "mcp-mongo-server"],
      "env": {
        "MCP_MONGODB_URI": "mongodb://localhost:27017/myDatabase"
      }
    }
  }
}

Prompts to try

Example prompts for exploring and querying MongoDB through Claude.

- "List all collections in the database and describe their schemas"
- "Find all users who signed up in the last 30 days and have not verified their email"
- "Run an aggregation to show total revenue per product category for 2024"
- "Show me the explain plan for this query: db.orders.find({ status: 'pending' })"
- "Insert a test document into the logs collection with a timestamp and message field"
- "Create an index on the email field in the users collection"

Troubleshooting MongoDB

Connection refused — cannot connect to MongoDB

Verify MongoDB is running with `mongosh` or `mongo` in a terminal. For local instances confirm it listens on port 27017. For Atlas, ensure your current IP address is whitelisted in the Atlas Network Access settings.

Authentication failed with credentials in the URI

URL-encode any special characters in the username or password (e.g. @ becomes %40, # becomes %23). Test the URI directly with `mongosh 'mongodb://user:pass@host/db'` to isolate authentication issues.

Write operation rejected even though read-only mode is not set

Check that MCP_MONGODB_READONLY is not accidentally set to 'true' in your environment. Also verify the MongoDB user in the connection URI has write permissions on the target database.

Frequently Asked Questions about MongoDB

What is MongoDB?

MongoDB is a Model Context Protocol (MCP) server that model context protocol (mcp) server that enables llms to interact directly with mongodb databases. query collections, inspect schemas, and manage data seamlessly through natural language. It connects AI assistants to external tools and data sources through a standardized interface.

How do I install MongoDB?

Install via npm with the command: npx -y mongodb. 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?

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

Is MongoDB free to use?

Yes, MongoDB is open source and available under the MIT License 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": { "command": "npx", "args": ["-y", "mongodb"] } } }

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

Read the full setup guide →

Ready to use MongoDB?

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