Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

mongodb-mcp-server

MCP server by mongodb-js Community

MongoDB MCP Server lets AI assistants interact with MongoDB databases and MongoDB Atlas. It is an official server from mongodb-js, run locally with npx or Docker. It works with self-managed deployments and Atlas clusters.

  • Score 94
  • 1.2k stars
  • 203k a week
  • Apache-2.0
  • Updated

Install mongodb-mcp-server

Built from the published package, never by AI.

claude mcp add mongodb-mcp-server -- npx -y mongodb-mcp-server

Run in your terminal. Add --scope user to use it in every project.

Step-by-step: install mongodb-mcp-server in Claude Code

MCP servers run with your permissions and can read what you give them access to. Some need an API key: check the README and add it under env in the mongodb-mcp-server block.

About

MongoDB MCP Server is an official Model Context Protocol server for interacting with MongoDB databases and MongoDB Atlas. It is published by mongodb-js as the mongodb-mcp-server package and is started with npx. It can connect with a MongoDB connection string, which the source says works for local instances and Atlas clusters, or with Atlas API service account credentials.

The server is aimed at developers and teams who want AI agents to search and manage their data. The README examples include the --readOnly flag by default, and write operations require removing it. MongoDB also offers an mongodb-atlas plugin that connects to the hosted Atlas MCP server over OAuth without running anything locally. A Docker image and an interactive setup command are documented as well.

Written from the project's README and checked against it.

What you need

  • Node.js v22.13.0 or later
  • A MongoDB connection string or Atlas API service account credentials
  • Docker (optional, for the container setup)
SettingNeededWhat it is
MDB_MCP_AGGREGATION_COUNT_MAX_TIME_MS_CAPEnvironment variableOptionalDeprecated. Use `aggregationCountTimeoutMs` instead.
MDB_MCP_AGGREGATION_COUNT_TIMEOUT_MSEnvironment variableOptionalThe maximum time in milliseconds for the count phase of aggregation operations. This is used to limit the time spent counting documents when determining if results were capped.
MDB_MCP_ALLOW_REQUEST_OVERRIDESEnvironment variableOptionalWhen set to true, allows configuration values to be overridden via request headers and query parameters.
MDB_MCP_API_CLIENT_IDEnvironment variable, secretOptionalAtlas API client ID for authentication. Required for running Atlas tools.
MDB_MCP_API_CLIENT_SECRETEnvironment variable, secretOptionalAtlas API client secret for authentication. Required for running Atlas tools.
MDB_MCP_ASSISTANT_BASE_URLEnvironment variableOptionalBase URL for the MongoDB Assistant API.
MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MSEnvironment variableOptionalTime in milliseconds that temporary database users created when connecting to MongoDB Atlas clusters will remain active before being automatically deleted.
MDB_MCP_CONFIRMATION_REQUIRED_TOOLSEnvironment variableOptionalComma separated values of tool names that require user confirmation before execution. Requires the client to support elicitation.
MDB_MCP_CONNECTION_CONNECT_TIMEOUT_MSEnvironment variableOptionalMilliseconds a MongoDB connection may stay in the 'connecting' state (e.g. an in-progress OIDC flow) before it is closed. Bounds a dial that never settles so it cannot pin a connection indefinitely. Kept separate from connectionIdleTimeoutM
MDB_MCP_CONNECTION_IDLE_TIMEOUT_MSEnvironment variableOptionalMilliseconds a MongoDB connection may stay unused (no tool call touching it) before it is closed to release the underlying connection pool and its server-side state. Applied per connection regardless of its connection scope; the preconfigur
MDB_MCP_CONNECTION_SCOPEEnvironment variableOptionalVisibility scope for MongoDB connections created at runtime. With 'session' (the default), each MCP session only sees the connections it created (plus the shared 'preconfigured' one) and they are closed when the session ends. With 'global',
MDB_MCP_CONNECTION_STRINGEnvironment variable, secretOptionalMongoDB connection string for direct database connections, exposed under the connectionId "preconfigured". Optional, if not set, you'll need to call the connect tool before interacting with MongoDB data. Deprecated: prefer the "preconfigure
MDB_MCP_CONNECTION_STRINGSEnvironment variable, secretOptionalMongoDB connection strings keyed by name, as a JSON object (e.g. {"preconfigured": "mongodb://...", "analytics": "mongodb://..."}). Each name becomes a connectionId that the MongoDB tools can use directly, so one server can reach several de
MDB_MCP_DANGEROUS_HOST_BINDINGEnvironment variableOptionalWhen set to true, allows binding the HTTP server (and monitoring server) to a non-loopback host such as 0.0.0.0, a LAN IP, or an empty host (all interfaces). Binding to a non-loopback host exposes the server to the entire network and can al
MDB_MCP_DISABLE_SERVER_SIDE_JSEnvironment variableOptionalWhen set to true, disallows the use of server-side JavaScript operators (such as $where, $function, and $accumulator) in query filters and aggregation pipelines.
MDB_MCP_DISABLE_UNTRUSTED_DATA_WARNINGEnvironment variableOptionalWhen set to true, tool responses include potentially untrusted data (such as documents or query results) as-is, without wrapping it in delimiters and a prompt-injection warning.
MDB_MCP_DISABLED_TOOLSEnvironment variableOptionalComma separated values of tool names, operation types, and/or categories of tools that will be disabled.
MDB_MCP_DRY_RUNEnvironment variableOptionalWhen true, runs the server in dry mode: dumps configuration and enabled tools, then exits without starting the server.
MDB_MCP_ELICITATION_TIMEOUT_MSEnvironment variableOptionalTime in milliseconds the user has to respond to an elicitation request (such as a tool confirmation prompt) before it fails.
MDB_MCP_EVICTION_IDLE_GRACE_M_SEnvironment variableOptionalHow long a session must be idle before it becomes eligible for least-recently-used eviction when the HTTP transport is at its maxSessions cap (only used when transport is 'http'). Swept back to idleTimeoutMs when larger.

From the publisher's entry in the official MCP Registry. Required settings are already in the install config below as placeholders.

Try asking

  • Show me the collections in my MongoDB database
  • Find documents in my orders collection that match a filter
  • Summarize the data in my Atlas cluster

Good to know

  • Examples use --readOnly by default, so write operations need that flag removed
  • Atlas tools require Atlas API service account credentials
  • Node 20.x support is deprecated
  • Remote MongoDB MCP server cannot be authenticated with a static API key over HTTP

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: README.md, package.json. This looks for known risky patterns and is not a full audit. How grades work

What you can do with it

  • Query MongoDB collections from an AI assistant
  • Manage databases on MongoDB Atlas
  • Connect agents to self-managed MongoDB deployments

Alternatives to mongodb-mcp-server

All alternatives →
Supabase supabase
97

Connects Supabase projects to AI assistants such as Cursor, Claude and Windsurf over the Model Context Protocol. It lets assistants manage tables, fetch config and query data in a Supabase project.

AAA Local and remote 172k/wk
ArcadeDB MCP Server ArcadeData
94

ArcadeDB MCP Server is the built-in Model Context Protocol server of the ArcadeDB multi-model database. It lets AI assistants and LLMs work with ArcadeDB's graph, document, time-series, vector and other data models. It suits people who already run ArcadeDB and want assistant access to it.

AAA Local 1.3k
DBHubbytebase
94

Connects MCP clients such as Claude Desktop, Cursor and VS Code to PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, ClickHouse and SQLite. It exposes two tools by default, with read-only mode and query timeouts available as guardrails.

AAA Local 343k/wk
MCP Toolbox for Databasesgoogleapis
94

MCP Toolbox for Databases is an open source MCP server that connects AI agents, IDEs and applications to enterprise databases. It provides prebuilt tools for exploring schemas and running queries, plus a framework for custom tools. It is aimed at developers building agents that need database access.

AAA Local 17k
MCP Toolbox for Databasesgoogleapis
94

Connects AI agents, IDEs and applications to enterprise databases through the Model Context Protocol. Offers prebuilt database tools for MCP clients and a framework for building custom tools for production agents.

AAA Local 17k
dbxt8y2
94

Query databases from AI coding agents using the connections already set up in DBX. The dbx MCP server suits developers who use Claude Code, Cursor, Windsurf, or another MCP-compatible agent.

AAA Local 32k

Compare with Supabase, ArcadeDB MCP Server or DBHub

mongodb-mcp-server: common questions

Does MongoDB MCP Server work with MongoDB Atlas?

Yes. The README says the server can connect to any MongoDB cluster, including Atlas clusters, and that Atlas tools require Atlas API service account credentials.

Is MongoDB MCP Server read-only by default?

The example configurations include the --readOnly flag by default to allow safe, read-only access. The README says to remove this flag to enable write operations.

Do I need to run a local server to use MongoDB with an AI agent?

No. The README says the mongodb-atlas plugin connects to the MongoDB-hosted Atlas MCP server over OAuth and does not require running anything locally.

How do I install mongodb-mcp-server?

In Claude Code run claude mcp add mongodb-mcp-server -- npx -y mongodb-mcp-server. For Claude Desktop, Cursor and VS Code, paste the config shown above and restart. See the install guides.

Is mongodb-mcp-server the official server?

mongodb-mcp-server is a community project by mongodb-js, not verified by a company domain.

Is mongodb-mcp-server free?

The code is published under the Apache-2.0 licence. The service it connects to may have its own pricing.

Is mongodb-mcp-server safe to use?

It scores 94 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to mongodb-mcp-server?

Similar MCP servers: Supabase, ArcadeDB MCP Server, DBHub, MCP Toolbox for Databases.

Does mongodb-mcp-server work with ChatGPT?

Not directly. It runs locally, and ChatGPT only connects to remote servers with a URL. Use it in Claude Code, Claude Desktop, Cursor, VS Code or Codex.

mongodb-mcp-server Install

Add to stack

Loading.