# MongoDB (MCP Server)

> Query MongoDB databases and manage Atlas clusters from AI agents

- Type: MCP server
- Publisher: MongoDB (official)
- Categories: Development, Data & Analytics
- Website: https://github.com/mongodb-js/mongodb-mcp-server
- Source: https://github.com/mongodb-js/mongodb-mcp-server
- Transport: stdio
- Launch command: npx -y mongodb-mcp-server@latest --readOnly
- Sign-in: api-key
- Environment variables: MDB_MCP_CONNECTION_STRING, MDB_MCP_API_CLIENT_ID, MDB_MCP_API_CLIENT_SECRET
- GitHub stars: 1100
- Listed: 2025-04-29

## About

MongoDB's official MCP server lets agents query and modify MongoDB databases and manage Atlas clusters, users and access lists. It runs locally via npx or Docker using a connection string and/or Atlas service account credentials, with a read-only mode available. An Atlas-managed OAuth remote server is also offered through client plugin marketplaces.

## Install

1. **Add the server to Codex**

   Codex CLI:

   ```bash
   codex mcp add mongodb --env MDB_MCP_CONNECTION_STRING=YOUR_MDB_MCP_CONNECTION_STRING --env MDB_MCP_API_CLIENT_ID=YOUR_MDB_MCP_API_CLIENT_ID --env MDB_MCP_API_CLIENT_SECRET=YOUR_MDB_MCP_API_CLIENT_SECRET -- npx -y mongodb-mcp-server@latest --readOnly
   ```

   config.toml:

   ```toml
   [mcp_servers.mongodb]
   command = "npx"
   args = ["-y", "mongodb-mcp-server@latest", "--readOnly"]
   
   [mcp_servers.mongodb.env]
   MDB_MCP_CONNECTION_STRING = "YOUR_MDB_MCP_CONNECTION_STRING"
   MDB_MCP_API_CLIENT_ID = "YOUR_MDB_MCP_API_CLIENT_ID"
   MDB_MCP_API_CLIENT_SECRET = "YOUR_MDB_MCP_API_CLIENT_SECRET"
   ```

   Agents SDK:

   ```python
   from agents import Agent, Runner
   from agents.mcp import MCPServerStdio
   
   async with MCPServerStdio(
       name="MongoDB",
       params={"command": "npx", "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"]},
   ) as server:
       agent = Agent(name="Assistant", mcp_servers=[server])
       result = await Runner.run(agent, "List the collections in the shop database")
       print(result.final_output)
   ```

## Tools

- `find`
- `aggregate`
- `insert-many`
- `update-many`
- `delete-many`
- `list-databases`
- `list-collections`
- `create-index`
- `db-stats`
- `atlas-list-clusters`
- `atlas-create-cluster`
- `atlas-create-db-user`

## Example prompts

- "List the collections in the shop database"
- "Find the 10 most recent orders over $500"
- "Create an index on users.email"
- "List my Atlas clusters"

## Also available as

- app: [MongoDB Atlas](https://chatgptplugins.directory/apps/mongodb-atlas.md)

## Related

- [Chrome DevTools MCP](https://chatgptplugins.directory/mcp/chrome-devtools.md): Let coding agents control and debug a live Chrome browser
- [Playwright MCP](https://chatgptplugins.directory/mcp/playwright.md): Browser automation for agents via Playwright accessibility snapshots
- [GitHub](https://chatgptplugins.directory/mcp/github.md): Manage repos, issues, pull requests and Actions from your AI agent
- [Context7](https://chatgptplugins.directory/mcp/context7.md): Pull up-to-date, version-specific library docs into your coding agent
- [Supabase](https://chatgptplugins.directory/mcp/supabase.md): Manage Supabase databases, migrations, edge functions and logs
- [Stripe](https://chatgptplugins.directory/mcp/stripe.md): Query and act on your Stripe account and search Stripe docs from any agent

---
Source: https://chatgptplugins.directory/mcp/mongodb · Index: https://chatgptplugins.directory/llms.txt · Independent and community-run. Not affiliated with or endorsed by OpenAI. ChatGPT is a trademark of OpenAI.
