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.
Install mongodb-mcp-server
Built from the published package, never by AI.
claude mcp add mongodb-mcp-server -- npx -y mongodb-mcp-serverRun in your terminal. Add --scope user to use it in every project.
{
"mcpServers": {
"mongodb-mcp-server": {
"args": [
"-y",
"mongodb-mcp-server"
],
"command": "npx"
}
}
}Settings, Developer, Edit config. Paste into claude_desktop_config.json and restart.
{
"mcpServers": {
"mongodb-mcp-server": {
"args": [
"-y",
"mongodb-mcp-server"
],
"command": "npx"
}
}
}Add to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (this project).
{
"servers": {
"mongodb-mcp-server": {
"args": [
"-y",
"mongodb-mcp-server"
],
"command": "npx"
}
}
}Add to .vscode/mcp.json. VS Code uses "servers", not "mcpServers".
codex mcp add mongodb-mcp-server -- npx -y mongodb-mcp-server{
"mcpServers": {
"mongodb-mcp-server": {
"args": [
"-y",
"mongodb-mcp-server"
],
"command": "npx"
}
}
}Add to ~/.gemini/config/mcp_config.json (all projects) or .agents/mcp_config.json (this project).
gemini mcp add mongodb-mcp-server npx -y mongodb-mcp-serverGemini CLI was replaced by Antigravity CLI in June 2026 and remains only for enterprise licences and paid API keys.
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)
| Setting | Needed | What it is |
|---|---|---|
MDB_Environment variable | Optional | Deprecated. Use `aggregationCountTimeoutMs` instead. |
MDB_Environment variable | Optional | The 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_Environment variable | Optional | When set to true, allows configuration values to be overridden via request headers and query parameters. |
MDB_Environment variable, secret | Optional | Atlas API client ID for authentication. Required for running Atlas tools. |
MDB_Environment variable, secret | Optional | Atlas API client secret for authentication. Required for running Atlas tools. |
MDB_Environment variable | Optional | Base URL for the MongoDB Assistant API. |
MDB_Environment variable | Optional | Time in milliseconds that temporary database users created when connecting to MongoDB Atlas clusters will remain active before being automatically deleted. |
MDB_Environment variable | Optional | Comma separated values of tool names that require user confirmation before execution. Requires the client to support elicitation. |
MDB_Environment variable | Optional | Milliseconds 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_Environment variable | Optional | Milliseconds 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_Environment variable | Optional | Visibility 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_Environment variable, secret | Optional | MongoDB 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_Environment variable, secret | Optional | MongoDB 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_Environment variable | Optional | When 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_Environment variable | Optional | When set to true, disallows the use of server-side JavaScript operators (such as $where, $function, and $accumulator) in query filters and aggregation pipelines. |
MDB_Environment variable | Optional | When 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_Environment variable | Optional | Comma separated values of tool names, operation types, and/or categories of tools that will be disabled. |
MDB_Environment variable | Optional | When true, runs the server in dry mode: dumps configuration and enabled tools, then exits without starting the server. |
MDB_Environment variable | Optional | Time in milliseconds the user has to respond to an elicitation request (such as a tool confirmation prompt) before it fails. |
MDB_Environment variable | Optional | How 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
ANo 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 →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.
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.
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.
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.
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.
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.
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.
