Set it up
-
Turn on MongoDB in your AI
In Claude: open Settings → Connectors and add MongoDB. In ChatGPT: Settings → Apps & Connectors.
-
Add it to your app once
Copy the short config below into your app. It just tells your AI where to find MongoDB.
-
Just ask
Tell it what you want in plain words — no special commands.
For example, say
“List all collections in my MongoDB database and show their document counts”
Need the exact config? Show it +
Add to your client
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": ["-y", "mongodb-mcp-server", "--connectionString", "mongodb://localhost:27017"]
}
}
}Paste into your client's MCP configuration file.
Get the skill
A ready-made skill that teaches your AI agent to use MongoDB well. MongoDB's official skills — connections, schema design, query optimization, Atlas.
npx skills add mongodb/agent-skills Ready-to-run prompts
If you ask, MongoDB does it. Copy one, paste it into Claude, Codex or ChatGPT, done. No setup.
Explore your collections
If you ask
“List collections in the app database and show me 3 sample documents from each”
Then
See what collections exist and inspect sample documents.
Draft an aggregation pipeline
If you ask
“Write an aggregation to count orders per customer, sorted by total spend descending, top 10”
Then
Let AI write complex aggregation pipelines based on what you want to know.
Investigate live data
If you ask
“Find users where lastLogin is older than 90 days and account status is active”
Then
Query live data to answer product or debugging questions.
Good to know
- · Use a database user with readOnly role for AI queries — never grant admin or write access casually
- · Large find() queries without limit can stream massive amounts of data into your context
- · Aggregation pipelines on production can be expensive — test them on a dev replica first
When to use
- ✓ You're working with a MongoDB database and want to run queries conversationally
- ✓ You need to explore an unfamiliar collection's document shape
- ✓ You're debugging aggregation pipelines and want AI to draft them
- ✓ You want quick read-only access to production data for support
When not to use
- × You use Postgres, MySQL, or DynamoDB (use those specific servers)
- × You want to give AI write access to production without review
- × You need Atlas Search, Change Streams, or advanced Atlas-only features
About
Imagine asking your AI: 'Find all users in my MongoDB who signed up this month' or 'What collections exist in the orders database?' — and it queries MongoDB directly. This server connects your AI to MongoDB so it can query collections, run aggregations, and inspect schemas through conversation.
The official MongoDB MCP server provides AI assistants with access to MongoDB databases and MongoDB Atlas. Query collections, inspect schemas, insert and update documents, run aggregations, and analyze data — through natural language.
Maintained by MongoDB with Atlas integration. Supports both local MongoDB instances and cloud Atlas clusters.
Workflows That Use MongoDB MCP
Works With
Also Consider
FAQ
What does MongoDB MCP do? +
Imagine asking your AI: 'Find all users in my MongoDB who signed up this month' or 'What collections exist in the orders database?' — and it queries MongoDB directly. This server connects your AI to MongoDB so it can query collections, run aggregations, and inspect schemas through conversation.
Do I need to know how to code? +
No. Turn it on in your AI's settings and ask in plain English — no terminal, no coding.
When should I use MongoDB MCP? +
Reach for it when you need to: You're working with a MongoDB database and want to run queries conversationally; You need to explore an unfamiliar collection's document shape; You're debugging aggregation pipelines and want AI to draft them; You want quick read-only access to production data for support.
When should I avoid MongoDB MCP? +
Skip it when: You use Postgres, MySQL, or DynamoDB (use those specific servers); You want to give AI write access to production without review; You need Atlas Search, Change Streams, or advanced Atlas-only features.
How do I install MongoDB MCP? +
In Claude Code, run: claude mcp add mongodb -- npx -y mongodb-mcp-server --connectionString mongodb://localhost:27017. Copy-paste configs for Claude Desktop, Cursor, and Windsurf are at the top of this page.