
How to add MCP MongoDB Server to Cursor
Let LLMs query, aggregate, and write to MongoDB with schema inference and read-only protection. Paste the config into ~/.cursor/mcp.json and restart Cursor.
Last updated June 14, 2026 · 279★ · stdio · no auth
Cursor config for MCP MongoDB Server
npx -y mcp-mongo-server mongodb://localhost:27017/database{
"mcpServers": {
"mcp-mongodb-server": {
"command": "npx",
"args": [
"-y",
"mcp-mongo-server",
"mongodb://username:password@localhost:27017/database"
]
}
}
}Setup steps
- 1Open Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
- 2Paste the MCP MongoDB 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 MCP MongoDB Server's tools to confirm it's connected.
Before you start
- Node.js with npx (to run the package), or Docker
- A reachable MongoDB instance and a connection URI
What MCP MongoDB Server can do in Cursor
queryExecute MongoDB queries with filter, projection, and limit options, plus an optional explain plan (e.g. executionStats).
aggregateRun MongoDB aggregation pipelines, with an optional explain plan (e.g. queryPlanner).
countCount documents in a collection that match a query.
updateModify documents matching a filter, with upsert and multi options (disabled in read-only mode).
insertInsert one or more new documents into a collection (disabled in read-only mode).
createIndexCreate one or more indexes on a collection, including unique and named indexes (disabled in read-only mode).
serverInfoGet MongoDB server details, with optional debug information.
Security
Credentials are passed through the MongoDB connection URI (in args or the MCP_MONGODB_URI env var), so they will be stored in plaintext in your MCP client config. Use the --read-only flag (or MCP_MONGODB_READONLY="true") to block write operations and route reads to a secondary; read-only mode also disables the update, insert, and createIndex tools.
MCP MongoDB Server + Cursor FAQ
Where is the Cursor config file?
Cursor reads MCP servers from ~/.cursor/mcp.json. Paste the MCP MongoDB Server config there under the "mcpServers" key and restart the client.
Is MCP MongoDB Server safe to use with Cursor?
Credentials are passed through the MongoDB connection URI (in args or the MCP_MONGODB_URI env var), so they will be stored in plaintext in your MCP client config. Use the --read-only flag (or MCP_MONGODB_READONLY="true") to block write operations and route reads to a secondary; read-only mode also disables the update, insert, and createIndex tools.
How do I run it in read-only mode?
Append the --read-only flag to the command args, or set the MCP_MONGODB_READONLY environment variable to "true". Read-only mode blocks write operations and uses a secondary read preference.
How do I provide the MongoDB connection string?
Pass the URI as a positional argument (e.g. npx -y mcp-mongo-server mongodb://user:pass@host:27017/db), or set the MCP_MONGODB_URI environment variable instead of an argument.
Can I use it without npm?
Yes. You can run it directly from GitHub (npx -y github:kiliczsh/mcp-mongo-server ...) or build and run the provided Docker image. Smithery and mcp-get automated installers are also documented.