Skip to content
MCP server

mongodb-lens

Local MCP server giving AI assistants natural-language access to MongoDB databases

Actively maintained

The repository was last updated 13 days ago and is published under MIT.

mongodb-lens is an open-source MCP server for databases. It is available on CLI, API, Self-hosted, macOS, Windows and Linux.

Pricing
Open source
Platforms
CLI, API, Self-hosted
What it can do
Can delete data (5 tools)
GitHub stars
207
Last commit
Language
JavaScript

Similar MCP servers

About mongodb-lens

Running as a local Model Context Protocol server, this project lets an MCP-capable AI client query, aggregate, and inspect MongoDB data without writing shell commands. It exposes a broad set of tools covering reads, writes, index management, schema inference, query plan analysis, and change streams, along with resources for stats and server status.

Safety is handled through several layers: a two-step token confirmation for destructive operations, a read-only mode that blocks write tools and pipeline stages, and field projection to keep sensitive values out of results sent to a remote model. Multiple named connection aliases let users switch between instances by name.

It suits developers and database administrators who want an assistant to explore collections, tune slow queries, or review schemas on local or remote MongoDB deployments. It can be launched through npx, Docker Hub, or a Node.js checkout.

Tools this server provides (42)

Taken from the project documentation; the running server may differ.

From the tool list in its README, going by the names, 5 of 42 tools delete data and 9 change data; 13 names don't say.

From the server's own tool labels and tool names; not verified by us.

find-documentsName suggests: reads
Run queries with filters, projections, and sorting
aggregate-data
Execute aggregation pipelines
analyze-query-patternsName suggests: reads
Analyze live queries and suggest optimizations
analyze-schemaName suggests: reads
Automatically infer collection schemas
bulk-operations
Perform multiple operations efficiently
clear-cache
Clear memory caches to ensure fresh data
collation-queryName suggests: reads
Find documents with language-specific collation rules
compare-schemas
Compare schemas between two collections
connect-mongodb
Connect to a different MongoDB URI
connect-original
Connect back to the original MongoDB URI used at startup
count-documentsName suggests: reads
Count documents matching specified criteria
create-collectionName suggests: changes
Create new collections with custom options
create-databaseName suggests: changes
Create a new database with option to switch to it
create-indexName suggests: changes
Create new indexes for performance optimization
create-timeseriesName suggests: changes
Create time series collections for temporal data
create-userName suggests: changes
Create new database users with specific roles
current-database
Show the current database context
delete-documentName suggests: deletes
Delete documents matching specified criteria
distinct-values
Extract unique values for any field
drop-collectionName suggests: deletes
Remove collections from the database
drop-databaseName suggests: deletes
Drop a database
drop-indexName suggests: deletes
Remove indexes from collections
drop-userName suggests: deletes
Remove database users
explain-queryName suggests: reads
Analyze query execution plans
export-dataName suggests: reads
Export query results in JSON or CSV format
generate-schema-validator
Generate JSON Schema validators
geo-queryName suggests: reads
Perform geospatial queries with various operators
get-statsName suggests: reads
Retrieve database or collection statistics
gridfs-operation
Manage large files with GridFS buckets
insert-documentName suggests: changes
Insert one or more documents into collections
list-collectionsName suggests: reads
Explore collections in the current database
list-connectionsName suggests: reads
View all available MongoDB connection aliases
list-databasesName suggests: reads
View all accessible databases
rename-collectionName suggests: changes
Rename existing collections
shard-statusName suggests: reads
View sharding configuration for databases and collections
text-searchName suggests: reads
Perform full-text search across text-indexed fields
transaction
Execute multiple operations in a single ACID transaction
update-documentName suggests: changes
Update documents matching specified criteria
use-database
Switch to a specific database context
validate-collectionName suggests: reads
Check for data inconsistencies
watch-changes
Monitor real-time changes to collections
add-connection-aliasName suggests: changes
Add a new MongoDB connection alias

What it does

Natural language queries
Find, count, aggregate, and update documents by describing what you want to an AI client.
Destructive operation confirmation
Deletes, drops, and similar actions require a short-lived token issued in a first step.
Read-only mode
A config switch blocks write tools and pipeline stages for safer exploration.
Query performance analysis
Explains query plans, profiles live query patterns, and suggests indexes.
Schema inference and validation
Infers collection schemas, compares them, and generates JSON Schema validators.
Multiple connection aliases
Save named MongoDB URIs in a config file and switch between them by name.

Good for

  • Exploring an unfamiliar MongoDB database through conversational queries
  • Diagnosing slow queries and getting index recommendations
  • Reviewing collection schemas before a migration or refactor
  • Exporting filtered query results to JSON or CSV
  • Testing risky changes against a restored backup copy with confirmation enabled

Pricing

Open source

Free and MIT-licensed.

Prices change. Check npmjs.com before you buy.

mongodb-lens FAQ

How do I run mongodb-lens?

Use npx -y mongodb-lens with an optional connection string, run the Docker Hub image, or run it from a Node.js clone.

Can mongodb-lens be made read-only?

Yes. Setting readOnly to true in the config blocks tools and pipeline stages that write, and a read-only database user adds another layer.

How are destructive operations protected?

The first call returns a 4-digit token that expires after five minutes, and the operation runs only when the token is supplied in a second call.

Which MongoDB versions are supported?

The latest release targets MongoDB 4.0 and above. Older servers need a 3.x driver or an earlier release such as 8.3.0.

Is mongodb-lens free?

Yes. mongodb-lens is open source, so you can use and self-host it for free.

What are the best alternatives to mongodb-lens?

The closest alternatives to mongodb-lens are mongo-mcp, mcp-mongo-server, Mongodb MCP Server, Mongo Scout MCP and MongoDB Read-Only MCP.

Where this comes from

  • Description: written from the project's README.

How AIPoweredBot checks servers