MCP Directory

MongoDB Lens

Full-featured MCP server for querying, aggregating, and managing MongoDB databases via natural language.

Unverified
stdio (local)
No auth
Stale
JavaScript

Add to your client

Copy the config for your MCP client and paste it into its config file.

Install / run
npx -y mongodb-lens@latest

Paste into ~/Library/Application Support/Claude/claude_desktop_config.json

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

Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf

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

About MongoDB Lens

MongoDB Lens is a local MCP server providing comprehensive, natural-language access to MongoDB databases for LLM clients such as Claude Desktop and Cursor. It bundles 40+ tools for CRUD, aggregation, schema analysis, indexing, performance optimization, administration, geospatial/text search, GridFS, transactions, and change streams, alongside MCP resources and guided prompts. Installation is easiest via NPX (Node.js >= 18.x), with Docker Hub and local source options also documented.

Tools & capabilities (41)

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).

analyze-schema

Automatically infer collection schemas.

compare-schemas

Compare schemas between two collections.

generate-schema-validator

Generate JSON Schema validators.

explain-query

Analyze query execution plans.

analyze-query-patterns

Analyze live queries and suggest optimizations.

create-index

Create new indexes for performance optimization.

drop-index

Remove indexes from collections (requires confirmation).

list-databases

View all accessible databases.

use-database

Switch to a specific database context.

create-database

Create a new database with option to switch to it.

drop-database

Drop a database (requires confirmation).

list-collections

Explore collections in the current database.

create-collection

Create new collections with custom options.

rename-collection

Rename existing collections (requires confirmation when dropping targets).

drop-collection

Remove collections from the database (requires confirmation).

validate-collection

Check for data inconsistencies.

create-timeseries

Create time series collections for temporal data.

text-search

Perform full-text search across text-indexed fields.

geo-query

Perform geospatial queries with various operators.

collation-query

Find documents with language-specific collation rules.

transaction

Execute multiple operations in a single ACID transaction.

gridfs-operation

Manage large files with GridFS buckets.

export-data

Export query results in JSON or CSV format.

watch-changes

Monitor real-time changes to collections.

get-stats

Retrieve database or collection statistics.

shard-status

View sharding configuration for databases and collections.

create-user

Create new database users with specific roles.

drop-user

Remove database users (requires confirmation).

add-connection-alias

Add a new MongoDB connection alias.

list-connections

View all available MongoDB connection aliases.

connect-mongodb

Connect to a different MongoDB URI.

connect-original

Connect back to the original MongoDB URI used at startup.

clear-cache

Clear memory caches to ensure fresh data.

What this server can do

MongoDB Lens provides tools for these capabilities — tap one to see every MCP server that does the same:

When to use it

  • Explore and query MongoDB databases conversationally without writing query syntax by hand
  • Build and refine aggregation pipelines step by step
  • Analyze and compare collection schemas and generate JSON Schema validators
  • Diagnose slow queries and get index recommendations to optimize performance
  • Perform administrative tasks such as managing collections, indexes, users, and time series data
  • Run geospatial, full-text, and collation-aware searches, and monitor real-time change streams

Security notes

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 FAQ

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.

Which MongoDB versions are supported?

MongoDB Lens is backwards compatible, supporting both modern and legacy MongoDB versions, and requires Node.js >= 18.x (>= 22.x recommended).

Alternatives to MongoDB Lens

Compare all alternatives →

Google's official MCP server with prebuilt BigQuery tools, querying datasets via Application Default Credentials.

Verified
stdio (local)
OAuth
Go
10 tools
Updated 15 days agoRepo

Read/write Postgres access plus index tuning, EXPLAIN plans, and database health analysis for AI agents.

Verified
stdio (local)
API key
Python
9 tools
Updated 3 months agoRepo

Official Supabase server: manage tables, run SQL, branches, configs and edge functions from your AI client.

Verified
HTTP (remote)
OAuth
TypeScript
12 tools
Updated 1 month agoRepo