
Mongodb Mcp Setup
Walk through MongoDB MCP authentication—connection string, Atlas API service account, or Atlas Local Docker—so your agent can query Atlas without missing env vars.
Overview
MongoDB MCP Setup is an agent skill for the Build phase that guides configuration of MongoDB MCP authentication via connection string, Atlas API credentials, or Atlas Local Docker.
Install
npx skills add https://github.com/mongodb/agent-skills --skill mongodb-mcp-setupWhat is this skill?
- Three auth paths: Option A connection string, Option B Atlas Admin API (recommended), Option C Atlas Local via Docker
- Interactive detection of the user environment with tailored env var instructions
- Documents MDB_MCP_CONNECTION_STRING vs MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET
- Atlas Local path for zero-credential local testing when Docker is available
- atlas-connect-cluster flow for dynamic cluster attachment under service-account auth
- 3 authentication options: connection string, Atlas API credentials, Atlas Local Docker
Adoption & trust: 1.1k installs on skills.sh; 131 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You installed the MongoDB MCP server but the agent cannot reach Atlas or a cluster because required MDB_MCP_* environment variables were never set.
Who is it for?
Builders connecting Claude Code, Cursor, or Codex to MongoDB Atlas or a local Atlas emulation through MCP for the first time.
Skip if: Designing document schemas, writing aggregation pipelines, or production hardening without reading MongoDB security docs separately.
When should I use this skill?
MongoDB MCP is installed but required environment variables are missing, or the user asks about connecting to MongoDB/Atlas without credentials configured.
What do I get? / Deliverables
You finish an interactive credential setup with the correct env vars and connection path so MongoDB MCP tools work in your agent client.
- Configured MDB_MCP_* environment variables
- Chosen auth path documentation for the team
Recommended Skills
Journey fit
Setup sits in Build → integrations because it wires an external data plane into the agent stack before you ship features. The skill is exclusively about MCP server configuration and credentials, not schema design or query authoring.
How it compares
Step-by-step MCP credential onboarding skill—not a database MCP server package and not a data modeling reference.
Common Questions / FAQ
Who is mongodb-mcp-setup for?
Solo devs and indie teams using agentic IDEs who have the MongoDB MCP binary or package installed but need Atlas or local connection variables configured correctly.
When should I use mongodb-mcp-setup?
During Build integrations when you add MongoDB MCP to your agent stack, when connection errors mention missing MDB_MCP_* vars, or when you ask how to connect Cursor to Atlas without manual DB users.
Is mongodb-mcp-setup safe to install?
The skill handles secrets configuration guidance; store API keys in env or a vault, never commit them. Review the Security Audits panel on this Prism page before install.
SKILL.md
READMESKILL.md - Mongodb Mcp Setup
# MongoDB MCP Server Setup This skill guides users through configuring the MongoDB MCP server for use with an agentic client. ## Overview The MongoDB MCP server requires authentication. Users have three options: 1. **Connection String** (Option A): Direct connection to a specific cluster - Quick setup for single cluster - Requires `MDB_MCP_CONNECTION_STRING` environment variable 2. **Service Account Credentials** (Option B): MongoDB Atlas Admin API access - **Recommended for Atlas users** - simplifies authentication and data access - Access to Atlas Admin API and dynamic cluster connection via `atlas-connect-cluster` - No manual DB user credential management - Requires `MDB_MCP_API_CLIENT_ID` and `MDB_MCP_API_CLIENT_SECRET` environment variables 3. **Atlas Local** (Option C): Local development with Docker - **Best for local testing** - zero configuration required - Runs Atlas locally in Docker, requires Docker installed - No credentials or cloud cluster access 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. ## Step 0: Detect Client Before anything else, determine which agentic client the user is running. This controls how credentials are configured in Step 1 and Step 5. Run: ```bash env | grep "^CODEX_" ``` - **If no `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. - **If any `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. ## Step 1: Check Existing Configuration Check whether credentials are already configured. **For shell-based clients** — check the current environment: ```bash 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): ```bash 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):** - If `MDB_MCP_CONNECTION_STRING` appears → connection string auth is configured - If both `MDB_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. - If `MDB_MCP_READ_ONLY` appears → read-only mode is enabled **Partial Configuration Handling:** - User wants to add read-only to existing setup (has auth, no read-only flag) → skip to Step 4 - User wants to switch authentication methods → explain they should remove the old credentials first (from `config.toml` for Codex, from their shell profile for shell-based clients), then proceed with Steps 2–5 - User wants to update credentials → skip to Step 5 **Important**: 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 serv