MCP server · Databases
MongoDB MCP server
The MongoDB MCP server is MongoDB’s official MCP server. It lets an assistant query and manage MongoDB databases and, with Atlas credentials, Atlas projects, clusters and users. It runs locally with npx mongodb-mcp-server@latest (Node.js 22.13 or newer) and needs a connection string; use --readOnly to block writes.
- Maintainer
- MongoDB (official)
- Licence
- Apache-2.0
- Runs
- Locally (npx)
- Sign-in
- A token or API key
- Registry version
- 3.4.0 (updated 2026-11-24)
- Last activity
- 2026-10-13
Overview
What can the MongoDB MCP server do?
MongoDB’s MCP server runs locally through npx and connects to any MongoDB deployment from a connection string, whether that is a local instance, a self-managed cluster or Atlas. With an Atlas service account it also exposes tools for the Atlas platform itself. Every configuration example in the README adds the --readOnly flag, which stops create, update and delete tools from being registered.
Pick it when an assistant needs to explore collections, infer a schema, run find or aggregation queries, or check indexes and query plans. Atlas users can list and create clusters, manage database users and IP access lists, read Performance Advisor suggestions and work with Atlas Stream Processing. For Atlas, MongoDB also offers a hosted server through its “mongodb-atlas” plugins, which sign in with OAuth. The local CLI has no built-in authentication and is meant for single-user use on your own machine.
Tools
Tools it gives the assistant
- find, aggregate, count and explain queries
- Collection schema, index and storage statistics
- Insert, update, delete and drop tools (blocked by --readOnly)
- Export of query results in EJSON
- Atlas projects, clusters, database users and access lists
- Atlas Performance Advisor, alerts and Stream Processing
- Atlas Local deployments and MongoDB knowledge-base search
Install
How do I install MongoDB MCP in Claude Code, Cursor or VS Code?
You need:
- Node.js 22.13 or newer (20.19 still works but is deprecated)
- A MongoDB connection string, or Atlas service account credentials for the Atlas tools
Run in your project. --scope local keeps the servers private to you in this project; use user for every project.
claude mcp add --env MDB_MCP_CONNECTION_STRING="${MDB_MCP_CONNECTION_STRING}" --scope local mongodb -- npx -y mongodb-mcp-server@latest --readOnly
claude mcp add --env MDB_MCP_CONNECTION_STRING="$env:MDB_MCP_CONNECTION_STRING" --scope local mongodb -- cmd /c npx -y 'mongodb-mcp-server@latest' --readOnly
- Set MDB_MCP_CONNECTION_STRING first, e.g. export MDB_MCP_CONNECTION_STRING=… in your shell. The command saves the value, not the variable.
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json · Windows: %APPDATA%\Claude\claude_desktop_config.json (Settings → Developer → Edit Config). Restart Claude after saving.
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>"
}
}
}
}
- Claude Desktop doesn’t read variables in this file: replace <MDB_MCP_CONNECTION_STRING> with the real values.
- This file contains your keys once filled in. It lives in your user folder; never commit or share it.
In your project, or ~/.cursor/mcp.json for every project.
{
"mcpServers": {
"mongodb": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "${env:MDB_MCP_CONNECTION_STRING}"
}
}
}
}
In your workspace. VS Code asks for each secret the first time a server starts and stores it securely.
{
"inputs": [
{
"type": "promptString",
"id": "mdb-mcp-connection-string",
"description": "MDB_MCP_CONNECTION_STRING",
"password": true
}
],
"servers": {
"mongodb": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "${input:mdb-mcp-connection-string}"
}
}
}
}
Need another app? Open MongoDB MCP Server in the MCP config generator for a shared project .mcp.json, Devin, or several servers at once; it writes one file per app. The snippets follow the setup in the server’s README, checked on 2026-10-14.
Is the MongoDB MCP server safe? Check before you install
- Without --readOnly (or MDB_MCP_READ_ONLY=true) the assistant can drop collections and databases and delete documents.
- Pass connection strings and Atlas credentials as environment variables, not command-line arguments, which can show up in process lists.
- The CLI has no authentication; never bind it to a non-loopback host or share it between users.
- A local MCP server runs with your user account’s permissions. Install it only from the source linked above. See how to choose a safe server.
FAQ
MongoDB MCP questions
Is the MongoDB MCP server official?
Yes. MongoDB publishes and maintains it, under the Apache-2.0 licence. Install it only from the source linked on this page, not from a copy in another directory.
Is MongoDB MCP server remote or local?
Local. Your MCP app starts it on your machine with npx, and it runs with your user account’s permissions.
Does MongoDB MCP server need an API key or account?
Yes. It needs an API key or token from the service, which you pass as an environment variable or header rather than writing it into the config file. You also need: Node.js 22.13 or newer (20.19 still works but is deprecated); A MongoDB connection string, or Atlas service account credentials for the Atlas tools.
Why it’s listed
Why we list it
Official, frequently released and covers both raw MongoDB data and the Atlas platform.
Related
Alternatives and related servers: databases
- Redis MCP Server
- ClickHouse MCP Server
- DuckDB / MotherDuck Local MCP Server
- mcp-server-qdrant
- Pinecone Developer MCP Server
- MCP Toolbox for Databases
All MCP serversMCP config generatorGuide: MCP servers in Claude CodeGuide: what is MCP?