MCP Directory

How to add MongoDB Lens to Cursor

Full-featured MCP server for querying, aggregating, and managing MongoDB databases via natural language. Paste the config into ~/.cursor/mcp.json and restart Cursor.

Last updated June 14, 2026 · 204 · stdio · no auth

Cursor config for MongoDB Lens

npx -y mongodb-lens@latest
{
  "mcpServers": {
    "mongodb-lens": {
      "command": "/path/to/npx",
      "args": [
        "-y",
        "mongodb-lens@latest",
        "mongodb://your-connection-string"
      ]
    }
  }
}

Setup steps

  1. 1Open Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
  2. 2Paste the MongoDB Lens config below into the "mcpServers" object.
  3. 3Fill in placeholder secrets, then save.
  4. 4Cursor reloads MCP servers automatically — check Settings → MCP for a green status dot.
  5. 5Ask Cursor to use one of MongoDB Lens's tools to confirm it's connected.

Before you start

  • Node.js (>= v18.x; >= v22.x recommended) for NPX/local installation, or Docker
  • A running MongoDB instance with a connection string (defaults to mongodb://localhost:27017)
  • An MCP-compatible client such as Claude Desktop or Cursor

What MongoDB Lens can do in Cursor

find-documents

Run queries with filters, projections, and sorting.

aggregate-data

Execute aggregation pipelines.

count-documents

Count documents matching specified criteria.

distinct-values

Extract unique values for any field.

insert-document

Insert one or more documents into collections.

update-document

Update documents matching specified criteria.

delete-document

Delete documents matching specified criteria (requires confirmation).

bulk-operations

Perform multiple operations efficiently (requires confirmation for destructive operations).

Security

Permissions are dictated by the MongoDB connection string user; using a read-only account prevents unintended writes/deletes. Destructive operations (drop-collection, drop-database, delete-document, drop-index, drop-user, etc.) require two-step token confirmation by default. This can be bypassed by setting CONFIG_DISABLE_DESTRUCTIVE_OPERATION_TOKENS=true, which executes destructive operations immediately without confirmation. Connection string passwords are obfuscated in logs.

MongoDB Lens + Cursor FAQ

Where is the Cursor config file?

Cursor reads MCP servers from ~/.cursor/mcp.json. Paste the MongoDB Lens config there under the "mcpServers" key and restart the client.

Is MongoDB Lens safe to use with Cursor?

Permissions are dictated by the MongoDB connection string user; using a read-only account prevents unintended writes/deletes. Destructive operations (drop-collection, drop-database, delete-document, drop-index, drop-user, etc.) require two-step token confirmation by default. This can be bypassed by setting CONFIG_DISABLE_DESTRUCTIVE_OPERATION_TOKENS=true, which executes destructive operations immediately without confirmation. Connection string passwords are obfuscated in logs.

What is the easiest way to run MongoDB Lens?

Run it with NPX: `npx -y mongodb-lens@latest` (optionally followed by your MongoDB connection string). Docker Hub and local Node.js/Docker installs are also supported.

How does it connect to my database?

Pass a MongoDB connection string as an argument (e.g. mongodb://your-connection-string). If omitted, it defaults to mongodb://localhost:27017. You can also define multiple named connection aliases.

How are destructive operations protected?

By default, destructive operations require a two-step token confirmation. You can bypass this in controlled environments by setting CONFIG_DISABLE_DESTRUCTIVE_OPERATION_TOKENS=true. Using a read-only MongoDB user also prevents writes and deletes.

View repo Full MongoDB Lens page