Add a new MongoDB connection alias
Execute aggregation pipelines
Analyze live queries and suggest optimizations
Automatically infer collection schemas
Perform multiple operations efficiently
Clear memory caches to ensure fresh data
Find documents with language-specific collation rules
Compare schemas between two collections
Connect to a different MongoDB URI
Connect back to the original MongoDB URI used at startup
Count documents matching specified criteria
Create new collections with custom options
Create a new database with option to switch to it
Create new indexes for performance optimization
Create time series collections for temporal data
Create new database users with specific roles
Show the current database context
Delete documents matching specified criteria
Extract unique values for any field
Remove collections from the database
MongoDB Lens is a powerful Model Context Protocol server that provides natural language access to MongoDB databases. It enables users to query, analyze, and manage MongoDB databases using conversational language through LLMs like Claude. With MongoDB Lens, you can perform complex database operations including queries, aggregations, schema analysis, index creation, and performance optimization without writing MongoDB syntax. The tool offers comprehensive database management capabilities while incorporating safeguards for destructive operations.
MongoDB Lens is a Model Context Protocol (MCP) server that allows you to interact with MongoDB databases using natural language through LLMs.
You can install MongoDB Lens using npm or Docker:
NPM Installation:
npm install -g mongodb-lens
Docker Installation:
docker pull furey/mongodb-lens
MongoDB Lens requires configuration to connect to your MongoDB databases. You can configure it in several ways:
Environment Variables:
MONGODB_URI
: Your MongoDB connection stringMONGODB_DB
: Default database to useMCP_PORT
: Port for the MCP server (default: 8000)Configuration File: You can create a configuration file using the provided script:
npx mongodb-lens-config
This will guide you through creating a configuration with multiple database connections.
Command Line Arguments:
mongodb-lens --uri mongodb://localhost:27017/mydb --port 8000
Using NPM:
mongodb-lens
Using Docker:
docker run -p 8000:8000 -e MONGODB_URI=mongodb://host.docker.internal:27017/mydb furey/mongodb-lens
To use MongoDB Lens with your LLM client (like Claude Desktop or Cursor), you need to configure the MCP server in your client settings:
Claude Desktop:
Cursor:
MongoDB Lens includes safety features to protect your data:
Once connected, you can interact with your MongoDB databases using natural language. Examples:
MongoDB Lens will translate these natural language requests into the appropriate MongoDB operations and return the results.