
How to add MongoDB MCP Server to Cursor
Official MongoDB server connecting Atlas, Community, or Enterprise deployments to AI tools. Paste the config into ~/.cursor/mcp.json and restart Cursor.
Last updated June 15, 2026 · 1.5k★ · stdio · apikey · official
Cursor config for MongoDB MCP Server
npx -y mongodb-mcp-server@latest --readOnly{
"mcpServers": {
"mongodb-mcp-server": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://<user>:<password>@<cluster-host>/<db>"
}
}
}
}Setup steps
- 1Open Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
- 2Paste the MongoDB MCP Server config below into the "mcpServers" object.
- 3Fill in placeholder secrets, then save.
- 4Cursor reloads MCP servers automatically — check Settings → MCP for a green status dot.
- 5Ask Cursor to use one of MongoDB MCP Server's tools to confirm it's connected.
Before you start
- Node.js v22.13.0 or later (Node 20.x support is deprecated)
- A MongoDB connection string for the deployment you want to access (Atlas, Community, or Enterprise), OR Atlas API Service Account credentials (Client ID + Secret) for Atlas control-plane tools
- For Atlas tools: an Atlas Service Account created in the Atlas UI under Access Manager, with the minimum required project/org roles
- Optionally Docker, if you prefer running the published container image instead of npx
What MongoDB MCP Server can do in Cursor
findRun a query against a collection and return matching documents
aggregateExecute an aggregation pipeline on a collection
countCount documents matching a filter
insert-manyInsert one or more documents into a collection
update-manyUpdate documents matching a filter
delete-manyDelete documents matching a filter
list-databasesList databases in the connected deployment
list-collectionsList collections in a database
Security
The connection string carries full database credentials, so keep it in env vars (never args) and use a scoped user. Pass --readOnly when the agent should not mutate or drop collections.
MongoDB MCP Server + Cursor FAQ
Where is the Cursor config file?
Cursor reads MCP servers from ~/.cursor/mcp.json. Paste the MongoDB MCP Server config there under the "mcpServers" key and restart the client.
Is MongoDB MCP Server safe to use with Cursor?
The connection string carries full database credentials, so keep it in env vars (never args) and use a scoped user. Pass --readOnly when the agent should not mutate or drop collections.
Does it work with self-hosted MongoDB or only Atlas?
Both. Database tools work against any MongoDB deployment via a connection string — Atlas, Community, or Enterprise. The atlas-* tools additionally require Atlas Service Account API credentials and only apply to Atlas.
How do I get Atlas API credentials?
Create a Service Account in the Atlas UI (Organization/Project Access Manager > Applications), copy the Client ID and Client Secret, and grant it the minimum roles needed for the operations you want to perform.
Can I stop an agent from modifying data?
Yes. Start the server with read-only mode enabled and it will only expose non-destructive tools. You can also require confirmation for specific tools and cap how many documents/bytes a query returns.