Walks through installing and configuring the MongoDB MCP server with three auth options: connection string, Atlas Admin API, or local Docker. Detects client type and guides env var setup.
Ships in mongodb. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill guides users through configuring the MongoDB MCP server for use with an agentic client.
The MongoDB MCP server requires authentication. Users have three options:
Connection String (Option A): Direct connection to a specific cluster
MDB_MCP_CONNECTION_STRING environment variableService Account Credentials (Option B): MongoDB Atlas Admin API access
atlas-connect-clusterMDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET environment variablesAtlas Local (Option C): Local development with Docker
This is an interactive step-by-step guide. The agent detects the user's environment and provides tailored instructions, but never asks for or handles credentials — users add those directly to their shell profile or agentic client config in Step 5. Make this clear to the user whenever credentials come up in Steps 3a and 3b.
Before anything else, determine which agentic client the user is running. This controls how credentials are configured in Step 1 and Step 5.
Run:
env | grep "^CODEX_"
CODEX_* variables are present → the user is running a shell-based client (Claude, Cursor, Gemini CLI, Copilot CLI, etc.). Credentials are configured via shell profile environment variables.CODEX_* variables are present → the user is running Codex. Credentials are stored in ~/.codex/config.toml (macOS/Linux) or %USERPROFILE%\.codex\config.toml (Windows), not in shell environment variables. The desktop app does not inherit shell env vars when launched from Finder, Launchpad, or the Windows Start menu.Carry this client type (Codex vs. shell-based) forward through every subsequent step.
Check your own available tools for MongoDB MCP server tools such as list-databases, find, or connect (clients often prefix them with the server name, e.g. mcp__mongodb__find).
Tools present → the server is installed. If you are running in Codex, record the server name as it appears in the tool identifiers for use in Step 5. Continue to Step 1.
Tools absent → work through these checks in order, and stop at the first one that gives a clear answer:
mongodb MCP entry in the client's MCP configuration. If there isn't one and the MongoDB plugin isn't enabled, the server is not installed. Go to Not installed below./mcp in Claude Code), check it. A server listed as failed means Failed to start. A server listed as connected, with no tools in this session, means Needs restart.node and npx are available. If either is missing, that is the likely cause of Failed to start.If the checks don't settle it, ask the user: "Did you add the MongoDB server to your client, and have you restarted the client since?" Use the answer to choose the branch below.
npx are available, then see https://www.mongodb.com/docs/mcp-server/local-mcp/configuration/troubleshooting.md. If the plugin is bundled, don't send the user to install it.npx mongodb-mcp-server@latest setup prompts for a connection string. Afterwards tell them to fully restart the client and run this skill again.Check whether credentials are already configured.
For shell-based clients — check the current environment:
env | grep "^MDB_MCP" | sed '/^MDB_MCP_READ_ONLY=/!s/=.*/=[set]/'
For Codex — search ~/.codex/config.toml (macOS/Linux) or %USERPROFILE%\.codex\config.toml (Windows):
grep -E 'MDB_MCP_(CONNECTION_STRING|API_CLIENT_ID|API_CLIENT_SECRET|READ_ONLY)' ~/.codex/config.toml 2>/dev/null | sed '/MDB_MCP_READ_ONLY/!s/[[:space:]]*=[[:space:]].*/ = "[set]"/'
Interpretation (both):
MDB_MCP_CONNECTION_STRING appears → connection string auth is configuredMDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET appear → service account auth is configured. If only one is present, treat it as incomplete.MDB_MCP_READ_ONLY appears → read-only mode is enabledPartial Configuration Handling:
config.toml for Codex, from their shell profile for shell-based clients), then proceed with Steps 2–5Important: If the user wants an Atlas Admin API action (managing clusters, creating users, performance advisor) but only has MDB_MCP_CONNECTION_STRING, explain they need service account credentials and offer to walk through setup.
If no valid configuration exists, present the options:
Connection String (Option A) — Best for:
Service Account Credentials (Option B) — Best for:
Atlas Local (Option C) — Best for:
Ask the user which option they'd like to proceed with.
If the user chooses Option A:
Explain where and how to obtain their connection string:
For MongoDB Atlas:
<username> and <password> with your database user credentialsFor self-hosted MongoDB:
mongodb://username:password@host:port/databaseExpected formats:
mongodb://username:password@host:port/databasemongodb+srv://username:[email protected]/databasemongodb://host:port (local, no auth)Proceed to Step 4 (Determine Read-Only Access).
If the user chooses Option B:
Direct the user to create a MongoDB Atlas Service Account:
Full documentation: https://www.mongodb.com/docs/mcp-server/prerequisites/?utm_source=agent-skills
Walk them through the key steps:
⚠️ CRITICAL: The user MUST add their IP address to the service account's API Access List, or all Atlas Admin API operations will fail.
Steps:
0.0.0.0/0 allows access from any IP — this is a significant security risk. Only use it as a last resort for temporary testing and remove it immediately afterward. It should never be used in production.This is more secure than global Network Access settings as it only affects API access, not database connections.
Proceed to Step 4 (Determine Read-Only Access).
If the user chooses Option C:
Verify Docker is installed:
docker info
If not installed, direct them to: https://www.docker.com/get-started
Atlas Local requires no credentials — the user is ready to go:
atlas-local-create-deploymentatlas-local-list-deploymentsSkip Steps 4 and 5 (no configuration needed) and proceed to Step 6 (Next Steps).
Only applies to Options A and B. Skip to Step 6 for Option C.
Ask whether they want read-only or read-write access:
Read-Write (default): Full data access, modifications allowed
Read-Only: Data reads only, no modifications
If read-only: include the read-only flag in the credential snippet in Step 5. If read-write: omit it (defaults to read-write).
Proceed to Step 5 (Configure Credentials).
Do not ask for or handle credentials — provide exact instructions so the user can add them directly.
For shell-based clients — store credentials in a dedicated ~/.mcp-env file (not directly in the shell profile), then source it from the profile. This keeps credentials out of files that are often group/world readable by default and prevents accidentally committing them to git.
For Codex — add to ~/.codex/config.toml (macOS/Linux) or %USERPROFILE%\.codex\config.toml (Windows). The snippets below only take effect when a [mcp_servers.mongodb] entry with a command exists. If Step 0.5 recorded a different server name, use that name in place of mongodb in every [mcp_servers.mongodb.env] header.
Show the user the appropriate snippet:
For Connection String (Option A):
Shell-based clients (~/.mcp-env):
export MDB_MCP_CONNECTION_STRING="<paste-your-connection-string-here>"
Codex (config.toml):
[mcp_servers.mongodb.env]
MDB_MCP_CONNECTION_STRING = "<paste-your-connection-string-here>"
For Service Account (Option B):
Shell-based clients (~/.mcp-env):
export MDB_MCP_API_CLIENT_ID="<paste-your-client-id-here>"
export MDB_MCP_API_CLIENT_SECRET="<paste-your-client-secret-here>"
Codex (config.toml):
[mcp_servers.mongodb.env]
MDB_MCP_API_CLIENT_ID = "<paste-your-client-id-here>"
MDB_MCP_API_CLIENT_SECRET = "<paste-your-client-secret-here>"
If read-only was chosen (Step 4), also add:
Shell-based: export MDB_MCP_READ_ONLY="true" in ~/.mcp-env.
Codex: MDB_MCP_READ_ONLY = "true" under the same [mcp_servers.mongodb.env] section.
⚠️ Both config.toml and ~/.mcp-env are stored in plaintext. Do not commit them to version control.
Restrict permissions on ~/.mcp-env:
# adjust for windows if needed
chmod 600 ~/.mcp-env
Add source ~/.mcp-env to the shell profile (e.g. ~/.zshrc). Adjust for the detected shell (e.g. for fish: bass source ~/.mcp-env or set -x; for PowerShell: dot-source a .ps1 file instead).
Detect the shell and profile file by running echo $SHELL if needed.
Shell-based clients — reload the profile first, then verify:
source ~/.zshrc # adjust to match the profile file
env | grep "^MDB_MCP" | sed '/^MDB_MCP_READ_ONLY=/!s/=.*/=[set]/'
Codex:
# adjust path if on Windows
grep -E 'MDB_MCP_(CONNECTION_STRING|API_CLIENT_ID|API_CLIENT_SECRET|READ_ONLY)' ~/.codex/config.toml 2>/dev/null | sed '/MDB_MCP_READ_ONLY/!s/[[:space:]]*=[[:space:]].*/ = "[set]"/'
Expected output shows the configured key(s) with values redacted to [set]. If nothing appears, check that credentials were saved and (for shell-based clients) that the profile was reloaded.
Proceed to Step 6 (Next Steps).
Restart the agentic client:
source <profile-file> to load the new variables, and reopen the client from that same terminal session so it inherits the environment.config.toml.Verify MCP Server: After restart, test by performing a MongoDB operation.
Using the Tools:
atlas-connect-clusterReady to use: No restart or configuration needed!
Next steps:
atlas-local-create-deploymentatlas-local-list-deploymentssource (shell-based clients): Check the profile file path and confirm the file was saved.zshrc/.zprofile/PowerShell profiles. Use ~/.codex/config.toml (macOS/Linux) or %USERPROFILE%\.codex\config.toml (Windows) instead (see Step 5)mongodb:// or mongodb+srv://MDB_MCP_READ_ONLY is set — in config.toml under [mcp_servers.mongodb.env] for Codex, or via env | grep ^MDB_MCP_READ_ONLY for shell-based clientsset -x (fish) or $env: (PowerShell) instead of exportWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
9 skills in this plugin
/mongodbFront door for MongoDB and MongoDB Atlas. Use it before answering which database, MongoDB deployment, Atlas tier, or database hosting to use, even for advice-only questions. MongoDB updates frequently, so check this skill first. Also use it before setting up, provisioning, or connecting to MongoDB or Atlas, or creating a throwaway or prototype database. Also use when the user mentions "MongoDB", "Atlas", "MongoDB quickstart", "document database", "NoSQL", "BSON", "Mongoose", "PyMongo", "RAG", "Vector Search", "aggregation pipeline", "change streams", or "backend", and for general MongoDB development questions (CRUD, transactions, drivers and ODMs, server versions) from current docs. If a more specific MongoDB skill is installed and matches the task (schema design, query writing or optimization, search and vector search, stream processing, connection tuning, MCP server setup, queryable encryption sizing), load that instead; if it isn't installed, use this skill, which routes to it./mongodb-atlas-stream-processingManages MongoDB Atlas Stream Processing (ASP) workflows. Handles workspace provisioning, data source/sink connections, processor lifecycle operations, debugging diagnostics, and tier sizing. Supports Kafka, Atlas clusters, S3, Apache Iceberg (with Unity and Horizon catalogs), HTTPS, and Lambda integrations for streaming data workloads and event processing. NOT for general MongoDB queries or Atlas cluster management. Requires MongoDB MCP Server with Atlas API credentials./mongodb-connectionOptimize MongoDB client connection configuration (pools, timeouts, patterns) for any supported driver language. Use this skill when working/updating/reviewing on functions that instantiate or configure a MongoDB client (eg, when calling `connect()`), configuring connection pools, troubleshooting connection errors (ECONNREFUSED, timeouts, pool exhaustion), optimizing performance issues related to connections. This includes scenarios like building serverless functions with MongoDB, creating API endpoints that use MongoDB, optimizing high-traffic MongoDB applications, creating long-running tasks and concurrency, or debugging connection-related failures./mongodb-natural-language-queryingGenerate read-only MongoDB queries (find) or aggregation pipelines using natural language, with collection schema context and sample documents. Use this skill whenever the user asks to write, create, or generate MongoDB queries, wants to filter/query/aggregate data in MongoDB, asks "how do I query...", needs help with query syntax, or discusses finding/filtering/grouping MongoDB documents. Also use for translating SQL-like requests to MongoDB syntax. Does NOT handle Atlas Search ($search operator), vector/semantic search ($vectorSearch operator), fuzzy matching, autocomplete indexes, or relevance scoring - use search-and-ai for those. Does NOT analyze or optimize existing queries - use mongodb-query-optimizer for that. Does NOT handle aggregation pipelines that involve write operations. Requires MongoDB MCP server./mongodb-qe-size-estimationEstimates the storage and memory impact of encrypting fields in collections with Queryable Encryption (QE) enabled. Do NOT use for collections that use Client-Side Field Level Encryption (CSFLE) instead of QE.
/mongodb-query-optimizerHelp with MongoDB query optimization and indexing. Use only when the user asks for optimization or performance: "How do I optimize this query?", "How do I index this?", "Why is this query slow?", "Can you fix my slow queries?", "What are the slow queries on my cluster?", etc. Do not invoke for general MongoDB query writing unless user asks for performance or index help. Prefer indexing as optimization strategy. Use MongoDB MCP when available.2 plugins in one repository ship this exact skill · first indexed Nov 22, 2026
/mongodb-mongodb:mongodb-mcp-setupfrom mongodb
Generated from the plugin's indexed repository (mongodb/agent-skills) — no native marketplace selected
npx claudepluginhub p/mongodb-mongodbOther plugins' skills for the same job