Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
Your own AI agent, running 24/7 with QwikClaw logoYour own AI agent, running 24/7 with QwikClaw

QwikClaw sets up and runs an always-on OpenClaw agent for you. One click, no config files, no server setup.

Deploy now
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 47,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here
MongoDB MCP logo

MongoDB MCP

mongodb-js/mongodb-mcp-server
1,064 starsv1.10.0STDIORegistry activeApache-2.0Updated 2026-06-24Official

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

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

Summary

MongoDB's MCP server connects an agent to your MongoDB or Atlas cluster, letting it explore collections, run queries, and manage data through MCP tools.

Connect from your MCP client

One-click install

Add this server to your editor with a single click. Fill in any required credentials afterward.

Claude Code

Run this once and Claude Code registers the server for you:

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

Claude Desktop

Add this to claude_desktop_config.json under Settings → Developer → Edit Config:

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server"
      ],
      "env": {
        "MDB_MCP_ALLOW_REQUEST_OVERRIDES": "<MDB_MCP_ALLOW_REQUEST_OVERRIDES>",
        "MDB_MCP_API_CLIENT_ID": "<MDB_MCP_API_CLIENT_ID>",
        "MDB_MCP_API_CLIENT_SECRET": "<MDB_MCP_API_CLIENT_SECRET>",
        "MDB_MCP_ASSISTANT_BASE_URL": "<MDB_MCP_ASSISTANT_BASE_URL>",
        "MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS": "<MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS>",
        "MDB_MCP_CONFIRMATION_REQUIRED_TOOLS": "<MDB_MCP_CONFIRMATION_REQUIRED_TOOLS>",
        "MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>",
        "MDB_MCP_DISABLED_TOOLS": "<MDB_MCP_DISABLED_TOOLS>",
        "MDB_MCP_DRY_RUN": "<MDB_MCP_DRY_RUN>",
        "MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS": "<MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS>",
        "MDB_MCP_EXPORT_TIMEOUT_MS": "<MDB_MCP_EXPORT_TIMEOUT_MS>",
        "MDB_MCP_EXPORTS_PATH": "<MDB_MCP_EXPORTS_PATH>",
        "MDB_MCP_EXTERNALLY_MANAGED_SESSIONS": "<MDB_MCP_EXTERNALLY_MANAGED_SESSIONS>",
        "MDB_MCP_HEALTH_CHECK_HOST": "<MDB_MCP_HEALTH_CHECK_HOST>",
        "MDB_MCP_HEALTH_CHECK_PORT": "<MDB_MCP_HEALTH_CHECK_PORT>",
        "MDB_MCP_HTTP_BODY_LIMIT": "<MDB_MCP_HTTP_BODY_LIMIT>",
        "MDB_MCP_HTTP_HEADERS": "<MDB_MCP_HTTP_HEADERS>",
        "MDB_MCP_HTTP_HOST": "<MDB_MCP_HTTP_HOST>",
        "MDB_MCP_HTTP_PORT": "<MDB_MCP_HTTP_PORT>",
        "MDB_MCP_HTTP_RESPONSE_TYPE": "<MDB_MCP_HTTP_RESPONSE_TYPE>",
        "MDB_MCP_IDLE_TIMEOUT_MS": "<MDB_MCP_IDLE_TIMEOUT_MS>",
        "MDB_MCP_INDEX_CHECK": "<MDB_MCP_INDEX_CHECK>",
        "MDB_MCP_LOG_PATH": "<MDB_MCP_LOG_PATH>",
        "MDB_MCP_LOGGERS": "<MDB_MCP_LOGGERS>",
        "MDB_MCP_MAX_BYTES_PER_QUERY": "<MDB_MCP_MAX_BYTES_PER_QUERY>",
        "MDB_MCP_MAX_DOCUMENTS_PER_QUERY": "<MDB_MCP_MAX_DOCUMENTS_PER_QUERY>",
        "MDB_MCP_MAX_TIME_M_S": "<MDB_MCP_MAX_TIME_M_S>",
        "MDB_MCP_MCP_CLIENT_LOG_LEVEL": "<MDB_MCP_MCP_CLIENT_LOG_LEVEL>",
        "MDB_MCP_MONITORING_SERVER_FEATURES": "<MDB_MCP_MONITORING_SERVER_FEATURES>",
        "MDB_MCP_MONITORING_SERVER_HOST": "<MDB_MCP_MONITORING_SERVER_HOST>",
        "MDB_MCP_MONITORING_SERVER_PORT": "<MDB_MCP_MONITORING_SERVER_PORT>",
        "MDB_MCP_NOTIFICATION_TIMEOUT_MS": "<MDB_MCP_NOTIFICATION_TIMEOUT_MS>",
        "MDB_MCP_PREVIEW_FEATURES": "<MDB_MCP_PREVIEW_FEATURES>",
        "MDB_MCP_READ_ONLY": "<MDB_MCP_READ_ONLY>",
        "MDB_MCP_TELEMETRY": "<MDB_MCP_TELEMETRY>",
        "MDB_MCP_TRANSPORT": "<MDB_MCP_TRANSPORT>",
        "MDB_MCP_VOYAGE_API_KEY": "<MDB_MCP_VOYAGE_API_KEY>"
      }
    }
  }
}

Cursor

Add this to .cursor/mcp.json in your project (or ~/.cursor/mcp.json for all projects):

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server"
      ],
      "env": {
        "MDB_MCP_ALLOW_REQUEST_OVERRIDES": "<MDB_MCP_ALLOW_REQUEST_OVERRIDES>",
        "MDB_MCP_API_CLIENT_ID": "<MDB_MCP_API_CLIENT_ID>",
        "MDB_MCP_API_CLIENT_SECRET": "<MDB_MCP_API_CLIENT_SECRET>",
        "MDB_MCP_ASSISTANT_BASE_URL": "<MDB_MCP_ASSISTANT_BASE_URL>",
        "MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS": "<MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS>",
        "MDB_MCP_CONFIRMATION_REQUIRED_TOOLS": "<MDB_MCP_CONFIRMATION_REQUIRED_TOOLS>",
        "MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>",
        "MDB_MCP_DISABLED_TOOLS": "<MDB_MCP_DISABLED_TOOLS>",
        "MDB_MCP_DRY_RUN": "<MDB_MCP_DRY_RUN>",
        "MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS": "<MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS>",
        "MDB_MCP_EXPORT_TIMEOUT_MS": "<MDB_MCP_EXPORT_TIMEOUT_MS>",
        "MDB_MCP_EXPORTS_PATH": "<MDB_MCP_EXPORTS_PATH>",
        "MDB_MCP_EXTERNALLY_MANAGED_SESSIONS": "<MDB_MCP_EXTERNALLY_MANAGED_SESSIONS>",
        "MDB_MCP_HEALTH_CHECK_HOST": "<MDB_MCP_HEALTH_CHECK_HOST>",
        "MDB_MCP_HEALTH_CHECK_PORT": "<MDB_MCP_HEALTH_CHECK_PORT>",
        "MDB_MCP_HTTP_BODY_LIMIT": "<MDB_MCP_HTTP_BODY_LIMIT>",
        "MDB_MCP_HTTP_HEADERS": "<MDB_MCP_HTTP_HEADERS>",
        "MDB_MCP_HTTP_HOST": "<MDB_MCP_HTTP_HOST>",
        "MDB_MCP_HTTP_PORT": "<MDB_MCP_HTTP_PORT>",
        "MDB_MCP_HTTP_RESPONSE_TYPE": "<MDB_MCP_HTTP_RESPONSE_TYPE>",
        "MDB_MCP_IDLE_TIMEOUT_MS": "<MDB_MCP_IDLE_TIMEOUT_MS>",
        "MDB_MCP_INDEX_CHECK": "<MDB_MCP_INDEX_CHECK>",
        "MDB_MCP_LOG_PATH": "<MDB_MCP_LOG_PATH>",
        "MDB_MCP_LOGGERS": "<MDB_MCP_LOGGERS>",
        "MDB_MCP_MAX_BYTES_PER_QUERY": "<MDB_MCP_MAX_BYTES_PER_QUERY>",
        "MDB_MCP_MAX_DOCUMENTS_PER_QUERY": "<MDB_MCP_MAX_DOCUMENTS_PER_QUERY>",
        "MDB_MCP_MAX_TIME_M_S": "<MDB_MCP_MAX_TIME_M_S>",
        "MDB_MCP_MCP_CLIENT_LOG_LEVEL": "<MDB_MCP_MCP_CLIENT_LOG_LEVEL>",
        "MDB_MCP_MONITORING_SERVER_FEATURES": "<MDB_MCP_MONITORING_SERVER_FEATURES>",
        "MDB_MCP_MONITORING_SERVER_HOST": "<MDB_MCP_MONITORING_SERVER_HOST>",
        "MDB_MCP_MONITORING_SERVER_PORT": "<MDB_MCP_MONITORING_SERVER_PORT>",
        "MDB_MCP_NOTIFICATION_TIMEOUT_MS": "<MDB_MCP_NOTIFICATION_TIMEOUT_MS>",
        "MDB_MCP_PREVIEW_FEATURES": "<MDB_MCP_PREVIEW_FEATURES>",
        "MDB_MCP_READ_ONLY": "<MDB_MCP_READ_ONLY>",
        "MDB_MCP_TELEMETRY": "<MDB_MCP_TELEMETRY>",
        "MDB_MCP_TRANSPORT": "<MDB_MCP_TRANSPORT>",
        "MDB_MCP_VOYAGE_API_KEY": "<MDB_MCP_VOYAGE_API_KEY>"
      }
    }
  }
}

Cline and other MCP clients

Most MCP clients accept the standard mcpServers JSON block:

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server"
      ],
      "env": {
        "MDB_MCP_ALLOW_REQUEST_OVERRIDES": "<MDB_MCP_ALLOW_REQUEST_OVERRIDES>",
        "MDB_MCP_API_CLIENT_ID": "<MDB_MCP_API_CLIENT_ID>",
        "MDB_MCP_API_CLIENT_SECRET": "<MDB_MCP_API_CLIENT_SECRET>",
        "MDB_MCP_ASSISTANT_BASE_URL": "<MDB_MCP_ASSISTANT_BASE_URL>",
        "MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS": "<MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS>",
        "MDB_MCP_CONFIRMATION_REQUIRED_TOOLS": "<MDB_MCP_CONFIRMATION_REQUIRED_TOOLS>",
        "MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>",
        "MDB_MCP_DISABLED_TOOLS": "<MDB_MCP_DISABLED_TOOLS>",
        "MDB_MCP_DRY_RUN": "<MDB_MCP_DRY_RUN>",
        "MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS": "<MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS>",
        "MDB_MCP_EXPORT_TIMEOUT_MS": "<MDB_MCP_EXPORT_TIMEOUT_MS>",
        "MDB_MCP_EXPORTS_PATH": "<MDB_MCP_EXPORTS_PATH>",
        "MDB_MCP_EXTERNALLY_MANAGED_SESSIONS": "<MDB_MCP_EXTERNALLY_MANAGED_SESSIONS>",
        "MDB_MCP_HEALTH_CHECK_HOST": "<MDB_MCP_HEALTH_CHECK_HOST>",
        "MDB_MCP_HEALTH_CHECK_PORT": "<MDB_MCP_HEALTH_CHECK_PORT>",
        "MDB_MCP_HTTP_BODY_LIMIT": "<MDB_MCP_HTTP_BODY_LIMIT>",
        "MDB_MCP_HTTP_HEADERS": "<MDB_MCP_HTTP_HEADERS>",
        "MDB_MCP_HTTP_HOST": "<MDB_MCP_HTTP_HOST>",
        "MDB_MCP_HTTP_PORT": "<MDB_MCP_HTTP_PORT>",
        "MDB_MCP_HTTP_RESPONSE_TYPE": "<MDB_MCP_HTTP_RESPONSE_TYPE>",
        "MDB_MCP_IDLE_TIMEOUT_MS": "<MDB_MCP_IDLE_TIMEOUT_MS>",
        "MDB_MCP_INDEX_CHECK": "<MDB_MCP_INDEX_CHECK>",
        "MDB_MCP_LOG_PATH": "<MDB_MCP_LOG_PATH>",
        "MDB_MCP_LOGGERS": "<MDB_MCP_LOGGERS>",
        "MDB_MCP_MAX_BYTES_PER_QUERY": "<MDB_MCP_MAX_BYTES_PER_QUERY>",
        "MDB_MCP_MAX_DOCUMENTS_PER_QUERY": "<MDB_MCP_MAX_DOCUMENTS_PER_QUERY>",
        "MDB_MCP_MAX_TIME_M_S": "<MDB_MCP_MAX_TIME_M_S>",
        "MDB_MCP_MCP_CLIENT_LOG_LEVEL": "<MDB_MCP_MCP_CLIENT_LOG_LEVEL>",
        "MDB_MCP_MONITORING_SERVER_FEATURES": "<MDB_MCP_MONITORING_SERVER_FEATURES>",
        "MDB_MCP_MONITORING_SERVER_HOST": "<MDB_MCP_MONITORING_SERVER_HOST>",
        "MDB_MCP_MONITORING_SERVER_PORT": "<MDB_MCP_MONITORING_SERVER_PORT>",
        "MDB_MCP_NOTIFICATION_TIMEOUT_MS": "<MDB_MCP_NOTIFICATION_TIMEOUT_MS>",
        "MDB_MCP_PREVIEW_FEATURES": "<MDB_MCP_PREVIEW_FEATURES>",
        "MDB_MCP_READ_ONLY": "<MDB_MCP_READ_ONLY>",
        "MDB_MCP_TELEMETRY": "<MDB_MCP_TELEMETRY>",
        "MDB_MCP_TRANSPORT": "<MDB_MCP_TRANSPORT>",
        "MDB_MCP_VOYAGE_API_KEY": "<MDB_MCP_VOYAGE_API_KEY>"
      }
    }
  }
}

Codex CLI

Register the server with OpenAI's Codex CLI — run this once, or add the equivalent block to ~/.codex/config.toml:

codex mcp add mongodb --env MDB_MCP_ALLOW_REQUEST_OVERRIDES=<MDB_MCP_ALLOW_REQUEST_OVERRIDES> --env MDB_MCP_API_CLIENT_ID=<MDB_MCP_API_CLIENT_ID> --env MDB_MCP_API_CLIENT_SECRET=<MDB_MCP_API_CLIENT_SECRET> --env MDB_MCP_ASSISTANT_BASE_URL=<MDB_MCP_ASSISTANT_BASE_URL> --env MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS=<MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS> --env MDB_MCP_CONFIRMATION_REQUIRED_TOOLS=<MDB_MCP_CONFIRMATION_REQUIRED_TOOLS> --env MDB_MCP_CONNECTION_STRING=<MDB_MCP_CONNECTION_STRING> --env MDB_MCP_DISABLED_TOOLS=<MDB_MCP_DISABLED_TOOLS> --env MDB_MCP_DRY_RUN=<MDB_MCP_DRY_RUN> --env MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS=<MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS> --env MDB_MCP_EXPORT_TIMEOUT_MS=<MDB_MCP_EXPORT_TIMEOUT_MS> --env MDB_MCP_EXPORTS_PATH=<MDB_MCP_EXPORTS_PATH> --env MDB_MCP_EXTERNALLY_MANAGED_SESSIONS=<MDB_MCP_EXTERNALLY_MANAGED_SESSIONS> --env MDB_MCP_HEALTH_CHECK_HOST=<MDB_MCP_HEALTH_CHECK_HOST> --env MDB_MCP_HEALTH_CHECK_PORT=<MDB_MCP_HEALTH_CHECK_PORT> --env MDB_MCP_HTTP_BODY_LIMIT=<MDB_MCP_HTTP_BODY_LIMIT> --env MDB_MCP_HTTP_HEADERS=<MDB_MCP_HTTP_HEADERS> --env MDB_MCP_HTTP_HOST=<MDB_MCP_HTTP_HOST> --env MDB_MCP_HTTP_PORT=<MDB_MCP_HTTP_PORT> --env MDB_MCP_HTTP_RESPONSE_TYPE=<MDB_MCP_HTTP_RESPONSE_TYPE> --env MDB_MCP_IDLE_TIMEOUT_MS=<MDB_MCP_IDLE_TIMEOUT_MS> --env MDB_MCP_INDEX_CHECK=<MDB_MCP_INDEX_CHECK> --env MDB_MCP_LOG_PATH=<MDB_MCP_LOG_PATH> --env MDB_MCP_LOGGERS=<MDB_MCP_LOGGERS> --env MDB_MCP_MAX_BYTES_PER_QUERY=<MDB_MCP_MAX_BYTES_PER_QUERY> --env MDB_MCP_MAX_DOCUMENTS_PER_QUERY=<MDB_MCP_MAX_DOCUMENTS_PER_QUERY> --env MDB_MCP_MAX_TIME_M_S=<MDB_MCP_MAX_TIME_M_S> --env MDB_MCP_MCP_CLIENT_LOG_LEVEL=<MDB_MCP_MCP_CLIENT_LOG_LEVEL> --env MDB_MCP_MONITORING_SERVER_FEATURES=<MDB_MCP_MONITORING_SERVER_FEATURES> --env MDB_MCP_MONITORING_SERVER_HOST=<MDB_MCP_MONITORING_SERVER_HOST> --env MDB_MCP_MONITORING_SERVER_PORT=<MDB_MCP_MONITORING_SERVER_PORT> --env MDB_MCP_NOTIFICATION_TIMEOUT_MS=<MDB_MCP_NOTIFICATION_TIMEOUT_MS> --env MDB_MCP_PREVIEW_FEATURES=<MDB_MCP_PREVIEW_FEATURES> --env MDB_MCP_READ_ONLY=<MDB_MCP_READ_ONLY> --env MDB_MCP_TELEMETRY=<MDB_MCP_TELEMETRY> --env MDB_MCP_TRANSPORT=<MDB_MCP_TRANSPORT> --env MDB_MCP_VOYAGE_API_KEY=<MDB_MCP_VOYAGE_API_KEY> -- npx -y mongodb-mcp-server

# or add to ~/.codex/config.toml:
[mcp_servers.mongodb]
command = "npx"
args = ["-y", "mongodb-mcp-server"]
[mcp_servers.mongodb.env]
MDB_MCP_ALLOW_REQUEST_OVERRIDES = "<MDB_MCP_ALLOW_REQUEST_OVERRIDES>"
MDB_MCP_API_CLIENT_ID = "<MDB_MCP_API_CLIENT_ID>"
MDB_MCP_API_CLIENT_SECRET = "<MDB_MCP_API_CLIENT_SECRET>"
MDB_MCP_ASSISTANT_BASE_URL = "<MDB_MCP_ASSISTANT_BASE_URL>"
MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS = "<MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS>"
MDB_MCP_CONFIRMATION_REQUIRED_TOOLS = "<MDB_MCP_CONFIRMATION_REQUIRED_TOOLS>"
MDB_MCP_CONNECTION_STRING = "<MDB_MCP_CONNECTION_STRING>"
MDB_MCP_DISABLED_TOOLS = "<MDB_MCP_DISABLED_TOOLS>"
MDB_MCP_DRY_RUN = "<MDB_MCP_DRY_RUN>"
MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS = "<MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS>"
MDB_MCP_EXPORT_TIMEOUT_MS = "<MDB_MCP_EXPORT_TIMEOUT_MS>"
MDB_MCP_EXPORTS_PATH = "<MDB_MCP_EXPORTS_PATH>"
MDB_MCP_EXTERNALLY_MANAGED_SESSIONS = "<MDB_MCP_EXTERNALLY_MANAGED_SESSIONS>"
MDB_MCP_HEALTH_CHECK_HOST = "<MDB_MCP_HEALTH_CHECK_HOST>"
MDB_MCP_HEALTH_CHECK_PORT = "<MDB_MCP_HEALTH_CHECK_PORT>"
MDB_MCP_HTTP_BODY_LIMIT = "<MDB_MCP_HTTP_BODY_LIMIT>"
MDB_MCP_HTTP_HEADERS = "<MDB_MCP_HTTP_HEADERS>"
MDB_MCP_HTTP_HOST = "<MDB_MCP_HTTP_HOST>"
MDB_MCP_HTTP_PORT = "<MDB_MCP_HTTP_PORT>"
MDB_MCP_HTTP_RESPONSE_TYPE = "<MDB_MCP_HTTP_RESPONSE_TYPE>"
MDB_MCP_IDLE_TIMEOUT_MS = "<MDB_MCP_IDLE_TIMEOUT_MS>"
MDB_MCP_INDEX_CHECK = "<MDB_MCP_INDEX_CHECK>"
MDB_MCP_LOG_PATH = "<MDB_MCP_LOG_PATH>"
MDB_MCP_LOGGERS = "<MDB_MCP_LOGGERS>"
MDB_MCP_MAX_BYTES_PER_QUERY = "<MDB_MCP_MAX_BYTES_PER_QUERY>"
MDB_MCP_MAX_DOCUMENTS_PER_QUERY = "<MDB_MCP_MAX_DOCUMENTS_PER_QUERY>"
MDB_MCP_MAX_TIME_M_S = "<MDB_MCP_MAX_TIME_M_S>"
MDB_MCP_MCP_CLIENT_LOG_LEVEL = "<MDB_MCP_MCP_CLIENT_LOG_LEVEL>"
MDB_MCP_MONITORING_SERVER_FEATURES = "<MDB_MCP_MONITORING_SERVER_FEATURES>"
MDB_MCP_MONITORING_SERVER_HOST = "<MDB_MCP_MONITORING_SERVER_HOST>"
MDB_MCP_MONITORING_SERVER_PORT = "<MDB_MCP_MONITORING_SERVER_PORT>"
MDB_MCP_NOTIFICATION_TIMEOUT_MS = "<MDB_MCP_NOTIFICATION_TIMEOUT_MS>"
MDB_MCP_PREVIEW_FEATURES = "<MDB_MCP_PREVIEW_FEATURES>"
MDB_MCP_READ_ONLY = "<MDB_MCP_READ_ONLY>"
MDB_MCP_TELEMETRY = "<MDB_MCP_TELEMETRY>"
MDB_MCP_TRANSPORT = "<MDB_MCP_TRANSPORT>"
MDB_MCP_VOYAGE_API_KEY = "<MDB_MCP_VOYAGE_API_KEY>"

OpenClaw

OpenClaw reads MCP servers from the mcp.servers section of ~/.openclaw/openclaw.json (managed via `openclaw mcp add` or the mcporter skill):

{
  "mcp": {
    "servers": {
      "mongodb": {
        "command": "npx",
        "args": [
          "-y",
          "mongodb-mcp-server"
        ],
        "env": {
          "MDB_MCP_ALLOW_REQUEST_OVERRIDES": "<MDB_MCP_ALLOW_REQUEST_OVERRIDES>",
          "MDB_MCP_API_CLIENT_ID": "<MDB_MCP_API_CLIENT_ID>",
          "MDB_MCP_API_CLIENT_SECRET": "<MDB_MCP_API_CLIENT_SECRET>",
          "MDB_MCP_ASSISTANT_BASE_URL": "<MDB_MCP_ASSISTANT_BASE_URL>",
          "MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS": "<MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS>",
          "MDB_MCP_CONFIRMATION_REQUIRED_TOOLS": "<MDB_MCP_CONFIRMATION_REQUIRED_TOOLS>",
          "MDB_MCP_CONNECTION_STRING": "<MDB_MCP_CONNECTION_STRING>",
          "MDB_MCP_DISABLED_TOOLS": "<MDB_MCP_DISABLED_TOOLS>",
          "MDB_MCP_DRY_RUN": "<MDB_MCP_DRY_RUN>",
          "MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS": "<MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS>",
          "MDB_MCP_EXPORT_TIMEOUT_MS": "<MDB_MCP_EXPORT_TIMEOUT_MS>",
          "MDB_MCP_EXPORTS_PATH": "<MDB_MCP_EXPORTS_PATH>",
          "MDB_MCP_EXTERNALLY_MANAGED_SESSIONS": "<MDB_MCP_EXTERNALLY_MANAGED_SESSIONS>",
          "MDB_MCP_HEALTH_CHECK_HOST": "<MDB_MCP_HEALTH_CHECK_HOST>",
          "MDB_MCP_HEALTH_CHECK_PORT": "<MDB_MCP_HEALTH_CHECK_PORT>",
          "MDB_MCP_HTTP_BODY_LIMIT": "<MDB_MCP_HTTP_BODY_LIMIT>",
          "MDB_MCP_HTTP_HEADERS": "<MDB_MCP_HTTP_HEADERS>",
          "MDB_MCP_HTTP_HOST": "<MDB_MCP_HTTP_HOST>",
          "MDB_MCP_HTTP_PORT": "<MDB_MCP_HTTP_PORT>",
          "MDB_MCP_HTTP_RESPONSE_TYPE": "<MDB_MCP_HTTP_RESPONSE_TYPE>",
          "MDB_MCP_IDLE_TIMEOUT_MS": "<MDB_MCP_IDLE_TIMEOUT_MS>",
          "MDB_MCP_INDEX_CHECK": "<MDB_MCP_INDEX_CHECK>",
          "MDB_MCP_LOG_PATH": "<MDB_MCP_LOG_PATH>",
          "MDB_MCP_LOGGERS": "<MDB_MCP_LOGGERS>",
          "MDB_MCP_MAX_BYTES_PER_QUERY": "<MDB_MCP_MAX_BYTES_PER_QUERY>",
          "MDB_MCP_MAX_DOCUMENTS_PER_QUERY": "<MDB_MCP_MAX_DOCUMENTS_PER_QUERY>",
          "MDB_MCP_MAX_TIME_M_S": "<MDB_MCP_MAX_TIME_M_S>",
          "MDB_MCP_MCP_CLIENT_LOG_LEVEL": "<MDB_MCP_MCP_CLIENT_LOG_LEVEL>",
          "MDB_MCP_MONITORING_SERVER_FEATURES": "<MDB_MCP_MONITORING_SERVER_FEATURES>",
          "MDB_MCP_MONITORING_SERVER_HOST": "<MDB_MCP_MONITORING_SERVER_HOST>",
          "MDB_MCP_MONITORING_SERVER_PORT": "<MDB_MCP_MONITORING_SERVER_PORT>",
          "MDB_MCP_NOTIFICATION_TIMEOUT_MS": "<MDB_MCP_NOTIFICATION_TIMEOUT_MS>",
          "MDB_MCP_PREVIEW_FEATURES": "<MDB_MCP_PREVIEW_FEATURES>",
          "MDB_MCP_READ_ONLY": "<MDB_MCP_READ_ONLY>",
          "MDB_MCP_TELEMETRY": "<MDB_MCP_TELEMETRY>",
          "MDB_MCP_TRANSPORT": "<MDB_MCP_TRANSPORT>",
          "MDB_MCP_VOYAGE_API_KEY": "<MDB_MCP_VOYAGE_API_KEY>"
        }
      }
    }
  }
}

Replace the <PLACEHOLDER> values with your own credentials — see the configuration table below.

Configuration

MongoDB MCP reads the following environment variables:

VariableRequired
MDB_MCP_ALLOW_REQUEST_OVERRIDESOptional
MDB_MCP_API_CLIENT_IDOptional
MDB_MCP_API_CLIENT_SECRETOptional
MDB_MCP_ASSISTANT_BASE_URLOptional
MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MSOptional
MDB_MCP_CONFIRMATION_REQUIRED_TOOLSOptional
MDB_MCP_CONNECTION_STRINGOptional
MDB_MCP_DISABLED_TOOLSOptional
MDB_MCP_DRY_RUNOptional
MDB_MCP_EXPORT_CLEANUP_INTERVAL_MSOptional
MDB_MCP_EXPORT_TIMEOUT_MSOptional
MDB_MCP_EXPORTS_PATHOptional
MDB_MCP_EXTERNALLY_MANAGED_SESSIONSOptional
MDB_MCP_HEALTH_CHECK_HOSTOptional
MDB_MCP_HEALTH_CHECK_PORTOptional
MDB_MCP_HTTP_BODY_LIMITOptional
MDB_MCP_HTTP_HEADERSOptional
MDB_MCP_HTTP_HOSTOptional
MDB_MCP_HTTP_PORTOptional
MDB_MCP_HTTP_RESPONSE_TYPEOptional
MDB_MCP_IDLE_TIMEOUT_MSOptional
MDB_MCP_INDEX_CHECKOptional
MDB_MCP_LOG_PATHOptional
MDB_MCP_LOGGERSOptional
MDB_MCP_MAX_BYTES_PER_QUERYOptional
MDB_MCP_MAX_DOCUMENTS_PER_QUERYOptional
MDB_MCP_MAX_TIME_M_SOptional
MDB_MCP_MCP_CLIENT_LOG_LEVELOptional
MDB_MCP_MONITORING_SERVER_FEATURESOptional
MDB_MCP_MONITORING_SERVER_HOSTOptional
MDB_MCP_MONITORING_SERVER_PORTOptional
MDB_MCP_NOTIFICATION_TIMEOUT_MSOptional
MDB_MCP_PREVIEW_FEATURESOptional
MDB_MCP_READ_ONLYOptional
MDB_MCP_TELEMETRYOptional
MDB_MCP_TRANSPORTOptional
MDB_MCP_VOYAGE_API_KEYOptional

README.md

![Install in VS Code](https://insiders.vscode.dev/redirect/mcp/install?name=mongodb&inputs=%5B%7B%22id%22%3A%22connection_string%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22MongoDB%20connection%20string%22%7D%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22mongodb-mcp-server%22%2C%22--readOnly%22%5D%2C%22env%22%3A%7B%22MDB_MCP_CONNECTION_STRING%22%3A%22%24%7Binput%3Aconnection_string%7D%22%7D%7D) ![Install in Cursor](https://cursor.com/en-US/install-mcp?name=MongoDB&config=eyJjb21tYW5kIjoibnB4IC15IG1vbmdvZGItbWNwLXNlcnZlciAtLXJlYWRPbmx5In0%3D)

MongoDB MCP Server

A Model Context Protocol server for interacting with MongoDB Databases and MongoDB Atlas.

📚 Table of Contents

<a name="getting-started"></a>

Prerequisites

[!NOTE] Node 20.x support is deprecated and will be removed in a future release. Please upgrade to Node 22.13 or later. See https://nodejs.org/en/blog/migrations/v20-to-v22 for migration details.

  • Node.js
  • At least v22.13.0. Check with node -v.
  • A MongoDB connection string or Atlas API credentials.
  • _Service Accounts Atlas API credentials_ are required to use the Atlas tools. You can create a service account in MongoDB Atlas and use its credentials for authentication. See Atlas API Access for more details.
  • If you have a MongoDB connection string, you can use it directly to connect to your MongoDB instance.

Setup

Quick Start

🔒 Security Recommendation 1: When using Atlas API credentials, be sure to assign only the minimum required permissions to your service account. See Atlas API Permissions for details.

🔒 Security Recommendation 2: For enhanced security, we strongly recommend using environment variables to pass sensitive configuration such as connection strings and API credentials instead of command line arguments. Command line arguments can be visible in process lists and logged in various system locations, potentially exposing your secrets. Environment variables provide a more secure way to handle sensitive information.

Most MCP clients require a configuration file to be created or modified to add the MCP server.

Note: The configuration file syntax can be different across clients. Please refer to the following links for the latest expected syntax:

  • Windsurf: https://docs.windsurf.com/windsurf/mcp
  • VSCode: https://code.visualstudio.com/docs/copilot/chat/mcp-servers
  • Claude Desktop: https://modelcontextprotocol.io/quickstart/user
  • Cursor: https://docs.cursor.com/context/model-context-protocol
  • Copilot CLI: https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli
  • Opencode CLI: https://opencode.ai/docs/mcp-servers

Default Safety Notice: All examples below include --readOnly by default to ensure safe, read-only access to your data. Remove --readOnly if you need to enable write operations.

Option 1: Connection String

You can pass your connection string via environment variables, make sure to use a valid username and password.

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

NOTE: The connection string can be configured to connect to any MongoDB cluster, whether it's a local instance or an Atlas cluster.

Option 2: Atlas API Credentials

Use your Atlas API Service Accounts credentials. Must follow all the steps in Atlas API Access section.

{
  "mcpServers": {
    "MongoDB": {
      "command": "npx",
      "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"],
      "env": {
        "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id",
        "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret"
      }
    }
  }
}

Option 3: Standalone Service using environment variables and command line arguments

You can source environment variables defined in a config file or explicitly set them like we do in the example below and run the server via npx.

# Set your credentials as environment variables first
export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id"
export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret"

# Then start the server
npx -y mongodb-mcp-server@latest --readOnly

💡 Platform Note: The examples above use Unix/Linux/macOS syntax. For Windows users, see Environment Variables for platform-specific instructions.

  • For a complete list of configuration options see Configuration Options
  • To configure your Atlas Service Accounts credentials please refer to Atlas API Access
  • Connection String via environment variables in the MCP file example
  • Atlas API credentials via environment variables in the MCP file example

Option 4: Using Docker

You can run the MongoDB MCP Server in a Docker container, which provides isolation and doesn't require a local Node.js installation.

Run with Environment Variables

You may provide either a MongoDB connection string OR Atlas API credentials:

Option A: No configuration
docker run --rm -i \
  mongodb/mongodb-mcp-server:latest
Option B: With MongoDB connection string
# Set your credentials as environment variables first
export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase"

# Then start the docker container
docker run --rm -i \
  -e MDB_MCP_CONNECTION_STRING \
  -e MDB_MCP_READ_ONLY="true" \
  mongodb/mongodb-mcp-server:latest

💡 Platform Note: The examples above use Unix/Linux/macOS syntax. For Windows users, see Environment Variables for platform-specific instructions.

Option C: With Atlas API credentials
# Set your credentials as environment variables first
export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id"
export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret"

# Then start the docker container
docker run --rm -i \
  -e MDB_MCP_API_CLIENT_ID \
  -e MDB_MCP_API_CLIENT_SECRET \
  -e MDB_MCP_READ_ONLY="true" \
  mongodb/mongodb-mcp-server:latest

💡 Platform Note: The examples above use Unix/Linux/macOS syntax. For Windows users, see Environment Variables for platform-specific instructions.

Docker in MCP Configuration File

Without options:

{
  "mcpServers": {
    "MongoDB": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-e",
        "MDB_MCP_READ_ONLY=true",
        "-i",
        "mongodb/mongodb-mcp-server:latest"
      ]
    }
  }
}

With connection string:

{
  "mcpServers": {
    "MongoDB": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "MDB_MCP_CONNECTION_STRING",
        "-e",
        "MDB_MCP_READ_ONLY=true",
        "mongodb/mongodb-mcp-server:latest"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:password@cluster.mongodb.net/myDatabase"
      }
    }
  }
}

With Atlas API credentials:

{
  "mcpServers": {
    "MongoDB": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "MDB_MCP_READ_ONLY=true",
        "-e",
        "MDB_MCP_API_CLIENT_ID",
        "-e",
        "MDB_MCP_API_CLIENT_SECRET",
        "mongodb/mongodb-mcp-server:latest"
      ],
      "env": {
        "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id",
        "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret"
      }
    }
  }
}

Option 5: Running as an HTTP Server

⚠️ Security Notice: This server now supports Streamable HTTP transport for remote connections. HTTP transport is NOT recommended for production use without implementing proper authentication and security measures.

Suggested Security Measures Examples:

  • Implement authentication (e.g., API gateway, reverse proxy)
  • Use HTTPS/TLS encryption
  • Deploy behind a firewall or in private networks
  • Implement rate limiting
  • Never expose directly to the internet

For more details, see MCP Security Best Practices.

You can run the MongoDB MCP Server as an HTTP server instead of the default stdio transport. This is useful if you want to interact with the server over HTTP, for example from a web client or to expose the server on a specific port.

To start the server with HTTP transport, use the --transport http option:

npx -y mongodb-mcp-server@latest --transport http

By default, the server will listen on http://127.0.0.1:3000. You can customize the host and port using the --httpHost and --httpPort options:

npx -y mongodb-mcp-server@latest --transport http --httpHost=0.0.0.0 --httpPort=8080
  • --httpHost (default: 127.0.0.1): The host to bind the HTTP server.
  • --httpPort (default: 3000): The port number for the HTTP server.

Note: The default transport is stdio, which is suitable for integration with most MCP clients. Use http transport if you need to interact with the server over HTTP.

Option 6: Copilot CLI

You can use the Copilot CLI to interactively add the MCP server:

/mcp add

Alternatively, create or edit the configuration file ~/.copilot/mcp-config.json and add:

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

For more information, see the Copilot CLI documentation.

Option 7: OpenCode

Create or edit your OpenCode config file (~/.config/opencode/opencode.json or project-specific ./opencode.json):

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "MongoDB": {
      "type": "local",
      "command": ["npx", "-y", "mongodb-mcp-server@latest", "--readOnly"],
      "enabled": true,
      "environment": {
        "MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase"
      }
    }
  }
}

For more information about configuring OpenCode as an MCP client, including the expected syntax and options, see the OpenCode MCP servers documentation.

🛠️ Supported Tools

Tool List

MongoDB Database Tools

  • aggregate - Run an aggregation against a MongoDB collection
  • aggregate-db - Run an aggregation against a MongoDB database
  • collection-indexes - Describe the indexes for a collection
  • collection-schema - Describe the schema for a collection
  • collection-storage-size - Gets the size of the collection
  • connect - Connect to a MongoDB instance
  • count - Gets the number of documents in a MongoDB collection using db.collection.count() and query as an optional filter parameter
  • create-collection - Creates a new collection in a database. If the database doesn't exist, it will be created automatically.
  • create-index - Create an index for a collection
  • db-stats - Returns statistics that reflect the use state of a single database
  • delete-many - Removes all documents that match the filter from a MongoDB collection
  • disconnect - Close a MongoDB connection and revoke its connectionId.
  • drop-collection - Removes a collection or view from the database. The method also removes any indexes associated with the dropped collection.
  • drop-database - Removes the specified database, deleting the associated data files
  • drop-index - Drop an index for the provided database and collection.
  • explain - Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method
  • export - Export a query or aggregation results in the specified EJSON format.
  • find - Run a find query against a MongoDB collection
  • insert-many - Insert an array of documents into a MongoDB collection. If the list of documents is above com.mongodb/maxRequestPayloadBytes, consider inserting them in batches.
  • list-collections - List all collections for a given database
  • list-connections - List the active MongoDB connections and their connectionIds. Use this to find a connectionId established earlier.
  • list-databases - List all databases for a MongoDB connection
  • mongodb-logs - Returns the most recent logged mongod events
  • rename-collection - Renames a collection in a MongoDB database
  • update-many - Updates all documents that match the specified filter for a collection. If the list of documents is above com.mongodb/maxRequestPayloadBytes, consider updating them in batches.

MongoDB Atlas Tools

  • atlas-connect-cluster - Connect to MongoDB Atlas cluster and get back a connectionId to pass to the other MongoDB tools. Each call establishes a new, independent connection — multiple connections can be active at the same time.
  • atlas-create-access-list - Allow Ip/CIDR ranges to access your MongoDB Atlas clusters.
  • atlas-create-cluster - Create a MongoDB Atlas cluster (M10–M80, replica set or single shard). Compute autoscaling is enabled by default: min instance size is set to the selected instance size, max is set two tiers above. Disk autoscaling is always enabled. Encryption at rest with customer-managed keys (CMK) is supported, the CMK provider must already have a valid encryption at rest configuration in the project. The tool returns immediately, use the atlas-inspect-cluster tool to poll the cluster state for readiness (state: IDLE). Connection strings are unavailable until the cluster reaches IDLE state.
  • atlas-create-db-user - Create an MongoDB Atlas database user
  • atlas-create-free-cluster - Create a free MongoDB Atlas cluster
  • atlas-create-project - Create a MongoDB Atlas project
  • atlas-get-performance-advisor - Get MongoDB Atlas performance advisor recommendations and suggestions, which includes the operations: suggested indexes, drop index suggestions, schema suggestions, and a sample of the most recent (max 50) slow query logs
  • atlas-inspect-access-list - Inspect Ip/CIDR ranges with access to your MongoDB Atlas clusters.
  • atlas-inspect-cluster - Inspect metadata of a MongoDB Atlas cluster
  • atlas-list-alerts - List triggered alerts for a MongoDB Atlas project. These are alerts Atlas has raised, not the alert configurations that define them. Defaults to OPEN alerts; set status to TRACKING or CLOSED to see others.
  • atlas-list-clusters - List MongoDB Atlas clusters
  • atlas-list-db-users - List MongoDB Atlas database users
  • atlas-list-orgs - List MongoDB Atlas organizations
  • atlas-list-projects - List MongoDB Atlas projects.
  • atlas-load-sample-dataset - Load a MongoDB sample dataset into an Atlas cluster, or check the status of a previously-initiated load. To start a new load, provide clusterName — the load runs asynchronously and the response includes a jobId and initial state. To check progress, call this tool again with jobId (sample dataset loads typically take 1–5 minutes). State can be WORKING, COMPLETED, or FAILED.
  • atlas-pause-resume-cluster - Pause or resume a dedicated (M10+) MongoDB Atlas cluster.
  • atlas-streams-build - Create Atlas Stream Processing resources. Use this tool for 'set up a Kafka pipeline', 'create a workspace', 'add a connection', or 'deploy a processor'. Use resource='workspace' to create a new workspace (specify cloud provider, region, and tier). Use resource='connection' to add a data source or sink to an existing workspace. Use resource='processor' to deploy a stream processor with a pipeline. Use resource='privatelink' to set up private networking. Typical workflow: create workspace → add connections → deploy processor.
  • atlas-streams-discover - Discover and inspect Atlas Stream Processing resources. Also use for 'why is my processor failing', 'what workspaces do I have', 'show processor stats', or 'check processor health'. Use 'list-workspaces' to see all workspaces in a project. Use inspect actions for details on a specific resource. Use 'diagnose-processor' for a combined health report including state, stats, connection health, and recent errors. Use 'get-networking' for PrivateLink and account details.
  • atlas-streams-manage - Manage Atlas Stream Processing resources: start/stop processors, modify pipelines, update configurations. Also use for 'change the pipeline', 'scale up my processor', or 'update my workspace tier'. Common workflow: action='stop-processor' → action='modify-processor' → action='start-processor'. Use atlas-streams-discover with action 'inspect-processor' to check state before managing.
  • atlas-streams-teardown - Delete Atlas Stream Processing resources. Also use for 'remove my workspace', 'disconnect a source', 'delete all processors', or 'clean up my streams environment'. Performs basic safety checks before deletion: summarizes counts of processors and connections, highlights connections referenced by processors where possible, and surfaces API errors if processors are still running when deletion is attempted. Use atlas-streams-discover to review resources before deleting.
  • atlas-upgrade-cluster - Upgrade a MongoDB Atlas cluster tier. Upgrades Free (M0) clusters to Flex or M10 Dedicated, or Flex clusters to M10 Dedicated. The upgrade path is determined automatically from the current tier unless overridden with targetTier. Note to LLM: If provider and region are not already known, ask for both together in a single question before calling this tool. Common region mappings by provider (default recommendation: AWS US_EAST_1):

AWS: "East Coast"/"Virginia"/"US East" → US_EAST_1, "Ohio" → US_EAST_2, "California"/"West Coast" → US_WEST_2, "Southeast Asia"/"APAC"/"Singapore" → AP_SOUTHEAST_1, "Europe"/"EU"/"Ireland" → EU_WEST_1. GCP: "Central US" → CENTRAL_US, "Western US" → WESTERN_US, "Southeast Asia"/"APAC" → SOUTHEASTERN_ASIA_PACIFIC, "Europe"/"EU" → WESTERN_EUROPE. AZURE: "East US" → US_EAST_2, "West US" → US_WEST_2, "Europe"/"EU" → EUROPE_NORTH.

NOTE: atlas tools are only available when you set credentials on configuration section.

MongoDB Atlas Local Tools

  • atlas-local-connect-deployment - Connect to a MongoDB Atlas Local deployment and get back a connectionId to pass to the other MongoDB tools
  • atlas-local-create-deployment - Create a MongoDB Atlas local deployment. Default image is preview. When the user does not specify an image tag, inform them that preview is used by default and provide this link for more information: https://hub.docker.com/r/mongodb/mongodb-atlas-local
  • atlas-local-delete-deployment - Delete a MongoDB Atlas local deployment
  • atlas-local-list-deployments - List MongoDB Atlas local deployments

MongoDB Assistant Tools

  • list-knowledge-sources - List available data sources in the MongoDB Assistant knowledge base. Use this to explore available data sources or to find search filter parameters to use in search-knowledge.
  • search-knowledge - Search for information in the MongoDB Assistant knowledge base. This includes official documentation, curated expert guidance, and other resources provided by MongoDB. Supports filtering by data source and version.

📄 Supported Resources

  • config - Server configuration, supplied by the user either as environment variables or as startup arguments with sensitive parameters redacted. The resource can be accessed under URI config://config.
  • debug - Debugging information for MongoDB connectivity issues. Tracks the last connectivity attempt and error information. The resource can be accessed under URI debug://mongodb.
  • exported-data - A resource template to access the data exported using the export tool. The template can be accessed under URI exported-data://{exportName} where exportName is the unique name for an export generated by the export tool.

Configuration

🔒 Security Best Practice: We strongly recommend using environment variables for sensitive configuration such as API credentials (MDB_MCP_API_CLIENT_ID, MDB_MCP_API_CLIENT_SECRET) and connection strings (MDB_MCP_CONNECTION_STRING) instead of command-line arguments. Environment variables are not visible in process lists and provide better security for your sensitive data.

The MongoDB MCP Server can be configured using multiple methods, with the following precedence (highest to lowest):

  1. Command-line arguments
  2. Environment variables
  3. Configuration File

Configuration Options

| Environment Variable / CLI Option | Default | Description | | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | MDB_MCP_ALLOW_REQUEST_OVERRIDES / --allowRequestOverrides | false | When set to true, allows configuration values to be overridden via request headers and query parameters. | | MDB_MCP_API_CLIENT_ID / --apiClientId | <not set> | Atlas API client ID for authentication. Required for running Atlas tools. | | MDB_MCP_API_CLIENT_SECRET / --apiClientSecret | <not set> | Atlas API client secret for authentication. Required for running Atlas tools. | | MDB_MCP_ASSISTANT_BASE_URL / --assistantBaseUrl | "https://knowledge.mongodb.com/api/v1/" | Base URL for the MongoDB Assistant API. | | MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS / --atlasTemporaryDatabaseUserLifetimeMs | 14400000 | Time in milliseconds that temporary database users created when connecting to MongoDB Atlas clusters will remain active before being automatically deleted. | | MDB_MCP_CONFIRMATION_REQUIRED_TOOLS / --confirmationRequiredTools | "atlas-create-access-list,atlas-create-db-user,drop-database,drop-collection,delete-many,drop-index,atlas-streams-manage,atlas-streams-teardown" | Comma separated values of tool names that require user confirmation before execution. Requires the client to support elicitation. | | MDB_MCP_CONNECTION_SCOPE / --connectionScope | "session" | 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 — recommended when the HTTP transport is exposed to multiple clients without authentication. With 'global', connections are shared across all sessions and survive session rotation. | | MDB_MCP_CONNECTION_STRING / --connectionString | <not set> | MongoDB connection string for direct database connections. Optional, if not set, you'll need to call the connect tool before interacting with MongoDB data. | | MDB_MCP_DISABLE_SERVER_SIDE_JS / --disableServerSideJs | true | 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_MCP_DISABLED_TOOLS / --disabledTools | "" | Comma separated values of tool names, operation types, and/or categories of tools that will be disabled. | | MDB_MCP_DRY_RUN / --dryRun | false | When true, runs the server in dry mode: dumps configuration and enabled tools, then exits without starting the server. | | MDB_MCP_ELICITATION_TIMEOUT_MS / --elicitationTimeoutMs | 300000 | Time in milliseconds the user has to respond to an elicitation request (such as a tool confirmation prompt) before it fails. | | MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS / --exportCleanupIntervalMs | 120000 | Time in milliseconds between export cleanup cycles that remove expired export files. | | MDB_MCP_EXPORT_TIMEOUT_MS / --exportTimeoutMs | 300000 | Time in milliseconds after which an export is considered expired and eligible for cleanup. | | MDB_MCP_EXPORTS_PATH / --exportsPath | see below\ | Folder to store exported data files. | | MDB_MCP_EXTERNALLY_MANAGED_SESSIONS / --externallyManagedSessions | false | When true, the HTTP transport allows requests with a session ID supplied externally through the 'mcp-session-id' header. When an external ID is supplied, the initialization request is optional. | | MDB_MCP_HEALTH_CHECK_HOST / --healthCheckHost | <not set> | Deprecated. Use monitoringServerHost instead. Host address to bind the healthCheck HTTP server to (only used when transport is 'http'). If provided, healthCheckPort must also be set. | | MDB_MCP_HEALTH_CHECK_PORT / --healthCheckPort | <not set> | Deprecated. Use monitoringServerPort instead. Port number for the healthCheck HTTP server (only used when transport is 'http'). If provided, healthCheckHost must also be set. | | MDB_MCP_HTTP_BODY_LIMIT / --httpBodyLimit | 102400 | Maximum size of the HTTP request body in bytes (only used when transport is 'http'). This value is passed as the optional limit parameter to the Express.js json() middleware. | | MDB_MCP_HTTP_HEADERS / --httpHeaders | "{}" | Header that the HTTP server will validate when making requests (only used when transport is 'http'). | | MDB_MCP_HTTP_HOST / --httpHost | "127.0.0.1" | Host address to bind the HTTP server to (only used when transport is 'http'). | | MDB_MCP_HTTP_PORT / --httpPort | 3000 | Port number for the HTTP server (only used when transport is 'http'). Use 0 for a random port. | | MDB_MCP_HTTP_RESPONSE_TYPE / --httpResponseType | "sse" | The HTTP response type for tool responses: 'sse' for Server-Sent Events, 'json' for standard JSON responses. | | MDB_MCP_IDLE_TIMEOUT_MS / --idleTimeoutMs | 600000 | Idle timeout for a client to disconnect (only applies to http transport). | | MDB_MCP_INDEX_CHECK / --indexCheck | false | When set to true, enforces that query operations must use an index, rejecting queries that perform a collection scan. | | MDB_MCP_LOG_PATH / --logPath | see below\ | Folder to store logs. | | MDB_MCP_LOGGERS / --loggers | "disk,mcp" see below\* | Comma separated values of logger types. | | MDB_MCP_MAX_ACTIVE_CONNECTIONS / --maxActiveConnections | 10 | Maximum number of MongoDB connections a single scope (an MCP session by default, see connectionScope) can hold open. When exceeded, the scope's least-recently-used connection is closed and its connectionId revoked. The preconfigured connection does not count towards the limit. | | MDB_MCP_MAX_BYTES_PER_QUERY / --maxBytesPerQuery | 16777216 | The maximum size in bytes for results from a find or aggregate tool call. This serves as an upper bound for the responseBytesLimit parameter in those tools. | | MDB_MCP_MAX_DOCUMENTS_PER_QUERY / --maxDocumentsPerQuery | 100 | The maximum number of documents that can be returned by a find or aggregate tool call. For the find tool, the effective limit will be the smaller of this value and the tool's limit parameter. | | MDB_MCP_MAX_SESSIONS / --maxSessions | 1000 | Maximum number of concurrent sessions the HTTP transport will hold in memory (only used when transport is 'http'). Each session holds a full server instance, transport, and timers, so choose a value based on your deployment's available memory; the default is a conservative safety net rather than a recommended production value. | | MDB_MCP_MAX_TIME_M_S / --maxTimeMS | <not set> | The maximum time in milliseconds that operations are allowed to run on the MongoDB server. When set, this value is passed as the maxTimeMS option to read operations such as find, aggregate, and count. | | MDB_MCP_MCP_CLIENT_LOG_LEVEL / --mcpClientLogLevel | "debug" | Minimum severity level for log messages forwarded to the MCP client. | | MDB_MCP_MONITORING_SERVER_FEATURES / --monitoringServerFeatures | "health-check" | Features to expose on the monitoring server (only used when transport is 'http' and monitoringServerHost/monitoringServerPort are set). | | MDB_MCP_MONITORING_SERVER_HOST / --monitoringServerHost | <not set> | Host address to bind the monitoring HTTP server to (only used when transport is 'http'). If provided, monitoringServerPort must also be set. | | MDB_MCP_MONITORING_SERVER_PORT / --monitoringServerPort | <not set> | Port number for the monitoring HTTP server (only used when transport is 'http'). If provided, monitoringServerHost must also be set. | | MDB_MCP_NOTIFICATION_TIMEOUT_MS / --notificationTimeoutMs | 540000 | Notification timeout for a client to be aware of disconnect (only applies to http transport). | | MDB_MCP_PREVIEW_FEATURES / --previewFeatures | "" | Comma separated values of preview features that are enabled. | | MDB_MCP_READ_ONLY / --readOnly | false | When set to true, only allows read, connect, and metadata operation types, disabling create/update/delete operations. | | MDB_MCP_TELEMETRY / --telemetry | "enabled" | When set to disabled, disables telemetry collection. | | MDB_MCP_TRANSPORT / --transport | "stdio" | Either 'stdio' or 'http'. | | MDB_MCP_VOYAGE_API_KEY / --voyageApiKey | "" | API key for Voyage AI embeddings service (required for creating Atlas Local deployments with auto-embed vector search capabilities). |

Logger Options

The loggers configuration option controls where logs are sent. You can specify one or more logger types as a comma-separated list. The available options are:

  • mcp: Sends logs to the MCP client (if supported by the client/transport).
  • disk: Writes logs to disk files. Log files are stored in the log path (see logPath above).
  • stderr: Outputs logs to standard error (stderr), useful for debugging or when running in containers.

Default: disk,mcp (logs are written to disk and sent to the MCP client).

You can combine multiple loggers, e.g. --loggers disk stderr or export MDB_MCP_LOGGERS="mcp,stderr".

Example: Set logger via environment variable
export MDB_MCP_LOGGERS="disk,stderr"

💡 Platform Note: For Windows users, see Environment Variables for platform-specific instructions.

Example: Set logger via command-line argument
npx -y mongodb-mcp-server@latest --loggers mcp stderr
Log File Location

When using the disk logger, log files are stored in:

  • Windows: %LOCALAPPDATA%\mongodb\mongodb-mcp\.app-logs
  • macOS/Linux: ~/.mongodb/mongodb-mcp/.app-logs

You can override the log directory with the logPath option.

🔒 Security Guideline: The user account running the MCP server must have both read and write permissions to the logPath directory. Ensure this directory is properly secured with appropriate file system permissions to prevent unauthorized access to log files.

Disabled Tools

You can disable specific tools or categories of tools by using the disabledTools option. This option accepts an array of strings, where each string can be a tool name, operation type, or category.

The way the array is constructed depends on the type of configuration method you use:

  • For environment variable configuration, use a comma-separated string: export MDB_MCP_DISABLED_TOOLS="create,update,delete,atlas,collectionSchema".
  • For command-line argument configuration, use a space-separated string: --disabledTools create update delete atlas collectionSchema.

Categories of tools:

  • atlas - MongoDB Atlas tools, such as list clusters, create cluster, etc.
  • mongodb - MongoDB database tools, such as find, aggregate, etc.

Operation types:

  • create - Tools that create resources, such as create cluster, insert document, etc.
  • update - Tools that update resources, such as update document, rename collection, etc.
  • delete - Tools that delete resources, such as delete document, drop collection, etc.
  • read - Tools that read resources, such as find, aggregate, list clusters, etc.
  • metadata - Tools that read metadata, such as list databases/collections/indexes, infer collection schema, etc.
  • connect - Tools that allow you to connect or switch the connection to a MongoDB instance. If this is disabled, you will need to provide a connection string through the config when starting the server.

Require Confirmation

If your client supports elicitation, you can set the MongoDB MCP server to request user confirmation before executing certain tools.

When a tool is marked as requiring confirmation, the server will send an elicitation request to the client. The client with elicitation support will then prompt the user for confirmation and send the response back to the server. If the client does not support elicitation, the tool will execute without confirmation.

You can set the confirmationRequiredTools configuration option to specify the names of tools which require confirmation. By default, the following tools have this setting enabled: drop-database, drop-collection, delete-many, atlas-create-db-user, atlas-create-access-list.

Read-Only Mode

The readOnly configuration option allows you to restrict the MCP server to only use tools with "read", "connect", and "metadata" operation types. When enabled, all tools that have "create", "update" or "delete" operation types will not be registered with the server.

This is useful for scenarios where you want to provide access to MongoDB data for analysis without allowing any modifications to the data or infrastructure.

You can enable read-only mode using:

  • Environment variable: export MDB_MCP_READ_ONLY=true
  • Command-line argument: --readOnly

💡 Platform Note: For Windows users, see Environment Variables for platform-specific instructions.

When read-only mode is active, you'll see a message in the server logs indicating which tools were prevented from registering due to this restriction.

Index Check Mode

The indexCheck configuration option allows you to enforce that query operations must use an index. When enabled, queries that perform a collection scan will be rejected to ensure better performance.

This is useful for scenarios where you want to ensure that database queries are optimized.

You can enable index check mode using:

  • Environment variable: export MDB_MCP_INDEX_CHECK=true
  • Command-line argument: --indexCheck

💡 Platform Note: For Windows users, see Environment Variables for platform-specific instructions.

When index check mode is active, you'll see an error message if a query is rejected due to not using an index.

Exports

The data exported by the export tool is temporarily stored in the configured exportsPath on the machine running the MCP server until cleaned up by the export cleanup process. If the exportsPath configuration is not provided, the following defaults are used:

  • Windows: %LOCALAPPDATA%\mongodb\mongodb-mcp\exports
  • macOS/Linux: `~/.mongodb/mongo

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Databases servers.