MongoDB, verified
MCP server by MongoDB · Verified
Query MongoDB databases and manage Atlas clusters from your AI assistant, with an optional read-only mode.
Install MongoDB
Runs on your machine. Your client starts it with this command:
Needs Node.js on your computer. The setup steps below show where the command goes in each client.
MDB_MCP_ALLOW_REQUEST_OVERRIDESoptional When set to true, allows configuration values to be overridden via request headers and query parameters.MDB_MCP_API_CLIENT_IDsecret optional Atlas API client ID for authentication. Required for running Atlas tools.MDB_MCP_API_CLIENT_SECRETsecret optional Atlas API client secret for authentication. Required for running Atlas tools.MDB_MCP_ASSISTANT_BASE_URLoptional Base URL for the MongoDB Assistant API.MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MSoptional Time in milliseconds that temporary database users created when connecting to MongoDB Atlas clusters will remain active before being…MDB_MCP_CONFIRMATION_REQUIRED_TOOLSoptional Comma separated values of tool names that require user confirmation before execution. Requires the client to support elicitation.
Share this server
Opens this page, with the install command and setup steps.
mcp.tc/i/mongodbAbout
Connects an AI assistant to MongoDB databases and MongoDB Atlas. It can work with data in self-managed or Atlas deployments through a connection string, and manage Atlas resources through the Atlas API. The README groups its tools into Atlas, database and MongoDB Assistant categories.
It runs locally over stdio as the npm package mongodb-mcp-server (also published as a Docker image) and needs Node.js 22.13 or later. Authentication uses a MongoDB connection string or Atlas service account API credentials, passed as environment variables. The --readOnly flag limits it to read operations. MongoDB also offers a hosted Atlas MCP server over OAuth through its agent plugins.
What you can do
- Connect to MongoDB deployments with a connection string
- Work with MongoDB data through database tools
- Manage MongoDB Atlas resources with Atlas API credentials
- Run in read-only mode with the --readOnly flag
- Disable tools or require confirmation for selected tools
- Disable server-side JavaScript operators in queries
Tools
MongoDB lists its tools only to clients with a key, so we can’t show them here.
Example prompts
List the collections in my MongoDB database
Find the 10 most recent orders in the orders collection
Show my Atlas clusters
Describe the indexes on the users collection
Set up
Every client starts MongoDB on your machine with the same command. Pick yours; the page remembers your choice.
Claude Code
- Run this in a terminal, in your project folder:
claude mcp add --transport stdio mongodb --env "MDB_MCP_API_CLIENT_ID=<YOUR_MDB_MCP_API_CLIENT_ID>" --env "MDB_MCP_API_CLIENT_SECRET=<YOUR_MDB_MCP_API_CLIENT_SECRET>" --env "MDB_MCP_CONNECTION_STRING=<YOUR_MDB_MCP_CONNECTION_STRING>" -- npx -y mongodb-mcp-server@latest --readOnly- Start Claude Code and type
/mcp. mongodb should show as connected.
Add --scope user to make it available in every project. Replace the placeholders with your own values.
Claude Desktop
- Open Settings → Developer → Edit Config. It opens
claude_desktop_config.json. Add:
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_API_CLIENT_ID": "<YOUR_MDB_MCP_API_CLIENT_ID>",
"MDB_MCP_API_CLIENT_SECRET": "<YOUR_MDB_MCP_API_CLIENT_SECRET>",
"MDB_MCP_CONNECTION_STRING": "<YOUR_MDB_MCP_CONNECTION_STRING>"
}
}
}
}- Save the file and restart Claude Desktop. Replace the placeholders with your own values.
Needs Node.js on your computer. The file lives in ~/Library/Application Support/Claude/ on macOS and %APPDATA%\Claude\ on Windows.
Cursor
Add to Cursor (opens in a new tab)
Or add it by hand to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (this project):
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_API_CLIENT_ID": "<YOUR_MDB_MCP_API_CLIENT_ID>",
"MDB_MCP_API_CLIENT_SECRET": "<YOUR_MDB_MCP_API_CLIENT_SECRET>",
"MDB_MCP_CONNECTION_STRING": "<YOUR_MDB_MCP_CONNECTION_STRING>"
}
}
}
}Needs Node.js on your computer. Replace the placeholders with your own values.
VS Code
Add it to .vscode/mcp.json. VS Code asks for the secret the first time and stores it securely:
{
"servers": {
"mongodb": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_API_CLIENT_ID": "${input:mdb-mcp-api-client-id}",
"MDB_MCP_API_CLIENT_SECRET": "${input:mdb-mcp-api-client-secret}",
"MDB_MCP_CONNECTION_STRING": "${input:mdb-mcp-connection-string}"
}
}
},
"inputs": [
{
"type": "promptString",
"id": "mdb-mcp-api-client-id",
"description": "MDB_MCP_API_CLIENT_ID",
"password": true
},
{
"type": "promptString",
"id": "mdb-mcp-api-client-secret",
"description": "MDB_MCP_API_CLIENT_SECRET",
"password": true
},
{
"type": "promptString",
"id": "mdb-mcp-connection-string",
"description": "MDB_MCP_CONNECTION_STRING",
"password": true
}
]
}Needs Node.js on your computer.
Devin Desktop
- Add it to
~/.config/devin/mcp_config.json(macOS and Linux) or%APPDATA%\devin\mcp_config.json(Windows):
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_API_CLIENT_ID": "<YOUR_MDB_MCP_API_CLIENT_ID>",
"MDB_MCP_API_CLIENT_SECRET": "<YOUR_MDB_MCP_API_CLIENT_SECRET>",
"MDB_MCP_CONNECTION_STRING": "<YOUR_MDB_MCP_CONNECTION_STRING>"
}
}
}
}- Refresh the MCP server list in Cascade. Replace the placeholders with your own values.
Devin Desktop is the new name for Windsurf.
Codex
codex mcp add mongodb --env "MDB_MCP_API_CLIENT_ID=<YOUR_MDB_MCP_API_CLIENT_ID>" --env "MDB_MCP_API_CLIENT_SECRET=<YOUR_MDB_MCP_API_CLIENT_SECRET>" --env "MDB_MCP_CONNECTION_STRING=<YOUR_MDB_MCP_CONNECTION_STRING>" -- npx -y mongodb-mcp-server@latest --readOnlyOr edit ~/.codex/config.toml directly:
[mcp_servers.mongodb]
command = "npx"
args = ["-y", "mongodb-mcp-server@latest", "--readOnly"]
env = { MDB_MCP_API_CLIENT_ID = "<YOUR_MDB_MCP_API_CLIENT_ID>", MDB_MCP_API_CLIENT_SECRET = "<YOUR_MDB_MCP_API_CLIENT_SECRET>", MDB_MCP_CONNECTION_STRING = "<YOUR_MDB_MCP_CONNECTION_STRING>" }Needs Node.js on your computer. Replace the placeholders with your own values.
Gemini CLI
gemini mcp add -e "MDB_MCP_API_CLIENT_ID=<YOUR_MDB_MCP_API_CLIENT_ID>" -e "MDB_MCP_API_CLIENT_SECRET=<YOUR_MDB_MCP_API_CLIENT_SECRET>" -e "MDB_MCP_CONNECTION_STRING=<YOUR_MDB_MCP_CONNECTION_STRING>" mongodb npx -- -y mongodb-mcp-server@latest --readOnlyThis adds it to the current project. Add -s user to use it everywhere.
Any client
Most clients that start local servers accept this shape:
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_API_CLIENT_ID": "<YOUR_MDB_MCP_API_CLIENT_ID>",
"MDB_MCP_API_CLIENT_SECRET": "<YOUR_MDB_MCP_API_CLIENT_SECRET>",
"MDB_MCP_CONNECTION_STRING": "<YOUR_MDB_MCP_CONNECTION_STRING>"
}
}
}
}Zed puts servers under context_servers in its settings, with the same command, args and env fields.
Needs Node.js on your computer. Replace the placeholders with your own values.
Embed
Show MongoDB in a README or on your site. Each embed links to this page, uses the server’s own install command, and sets no cookies. How embeds work
The card, the iframe and the JSON are in English. Add ?lang=it, fr, de or es to their address for another language.
README badge
[](https://mcp.tc/i/mongodb)<a href="https://mcp.tc/i/mongodb"><img src="https://mcp.tc/i/mongodb/badge.svg" alt="MongoDB on mcp.tc" height="20"></a>It follows the reader’s light or dark mode. Add ?theme=light or ?theme=dark to fix it, or ?style=compact to show the mark without the word.
Website card
<script src="https://mcp.tc/w/mongodb.js" async></script>The card appears where the tag is. Add data-theme="dark" or data-size="compact" to the tag to change it. The file holds everything it needs, so it makes no other requests and sets no cookies.
iframe
<iframe src="https://mcp.tc/embed/mongodb" title="MongoDB on mcp.tc" width="420" height="200" loading="lazy" allow="clipboard-write" style="border:0;border-radius:8px;max-width:100%"></iframe>Use it on pages that don’t allow scripts. Add ?theme=light or ?theme=dark to the address to fix the colors.
JSON
The listing as data for your own pages and tools: name, tagline, install command, tools and the “Add to” links. Any site can read it (CORS is open).
https://mcp.tc/i/mongodb.jsonAI prompt
Paste this into an AI coding assistant, such as Claude Code or Cursor, and it adds the MongoDB card to your site.
Add the mcp.tc card for MongoDB, an MCP server, to my website. It is one static script: no build step, no package to install, no cookies.
Put this tag where the card should appear. The card renders right before it:
```html
<script src="https://mcp.tc/w/mongodb.js" async></script>
```
To show the card somewhere else, put this placeholder there and load the same script once, for example before `</body>`. Keep the link inside: visitors without JavaScript see it.
```html
<div data-mcptc="mongodb"><a href="https://mcp.tc/i/mongodb">MongoDB on mcp.tc</a></div>
```
Options:
- `data-theme="light"` or `"dark"` on the tag or the placeholder fixes the colors. Without it, the card follows the visitor’s light or dark mode.
- `data-size="compact"` gives a smaller card without the tagline.
- The CSS variable `--mcptc-max-width` on the placeholder or a parent sets the width (default `520px`).
- `?lang=` on the script URL sets the card’s language: `en`, `it`, `fr`, `de` or `es`.
If the site has a Content Security Policy, allow `script-src https://mcp.tc` and `img-src data:` (the icon is inline).
For a README or other Markdown docs, use the badge instead:
```markdown
[](https://mcp.tc/i/mongodb)
```
Reference: https://mcp.tc/embedChange history
This server runs on your computer, so we follow its npm package: each new version shows up here, with edits by its owner.
FAQ
Can I paste mcp.tc/i/mongodb into my MCP client?
No. MongoDB runs on your own computer, started by your client, so it has no web address to connect to. The quick link is the page to share; the install command is npx -y mongodb-mcp-server@latest --readOnly.
Does MongoDB need an API key?
Yes. It reads MDB_MCP_API_CLIENT_ID, MDB_MCP_API_CLIENT_SECRET and MDB_MCP_CONNECTION_STRING from its environment, and MDB_MCP_API_CLIENT_ID, MDB_MCP_API_CLIENT_SECRET and MDB_MCP_CONNECTION_STRING are secrets. Put the values in your client’s config on your own machine, never in a shared file.
Is MongoDB a remote or a local server?
Local. Your client starts it as a process on your computer with npx -y mongodb-mcp-server@latest --readOnly, which needs Node.js.
What can MongoDB do?
You can connect to MongoDB deployments with a connection string, work with MongoDB data through database tools and manage MongoDB Atlas resources with Atlas API credentials.
Which clients can use it?
Any client that starts local servers: Claude Code, Claude Desktop, Cursor, VS Code, Devin Desktop, Codex, Gemini CLI, Zed and others. claude.ai and ChatGPT only connect to remote servers.
Does mcp.tc track changes to MongoDB?
Partly. It runs on your computer, so we follow its npm package: its History tab shows each new version and edits by its owner. Follow the listing to get an email when it changes.
Who wrote this page?
mcp.tc’s robot read MongoDB’s public metadata (its package and repository pages), and an AI model drafted the text from it. A person reviews anything the checks can’t confirm. The text can still be wrong, so if you spot a mistake, use Report this listing on this page.
mcp.tc isn’t affiliated with MongoDB. This page was built from MongoDB’s public metadata, last checked on 3 Oct 2026, and an AI model wrote the description, so it can be wrong. Names and marks belong to their owners. Something off? Report this listing.