MongoDB Lens
About
Integrates with MongoDB databases to enable browsing collections, executing queries, running aggregation pipelines, analyzing schemas, and optimizing performance through specialized database exploration tools.
Details
- Author
- furey
- Repository
- furey/mongodb-lens
- GitHub stars
- 87
- Downloads
- 574
- License
- MIT License
- Categories
- Database, Community, Other, Productivity, Developer Tools, Design, AI, Search, Project Management, Infrastructure, Frontend
Jump to
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MongoDB LensCommand (node, npx, python, etc.)/path/to/npxArguments-
Argument 1
-y -
Argument 2
mongodb-lens@latest -
Argument 3
mongodb://your-connection-string
Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
-
Argument 1
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
- MongoDB Connection String
- Config File
- Config File Generation
- Multiple MongoDB Connections
- Environment Variable Overrides
- Cross-Platform Environment Variables
> [!NOTE]<br>
> NPX requires Node.js installed and running on your system (suggestion: use Volta).
The easiest way to run MongoDB Lens is using NPX.
First, ensure Node.js is installed:
node --version # Ideally >= v22.x but MongoDB Lens is >= v18.x compatible
Then, run MongoDB Lens via NPX:
> [!NOTE]<br>
> Docker Hub requires Docker installed and running on your system.
First, ensure Docker is installed:
consoledocker --version # Ideally >= v27.x
Then, run MongoDB Lens via Docker Hub:
console
> [!NOTE]<br>
> Node.js from source requires Node.js installed and running on your system (suggestion: use Volta).
1. Clone the MongoDB Lens repository:<br>
git clone https://github.com/furey/mongodb-lens.git
1. Navigate to the cloned repository directory:<br>
cd /path/to/mongodb-lens
1. Ensure Node.js is installed:<br>
node --version # Ideally >= v22.x but MongoDB Lens is >= v18.x compatible
1. Install Node.js dependencies:<br>
npm ci
1. Start the server:<br>
> [!NOTE]<br>
> Docker from source requires Docker installed and running on your system.
1. Clone the MongoDB Lens repository:<br>
consolegit clone https://github.com/furey/mongodb-lens.git
1. Navigate to the cloned repository directory:<br>
consolecd /path/to/mongodb-lens
1. Ensure Docker is installed:<br>
consoledocker --version # Ideally >= v27.x
1. Build the Docker image:<br>
consoledocker build -t mongodb-lens .
1. Run the container:<br>
console
To verify the installation, paste and run the following JSONRPC message into the server's stdio:
{"method":"resources/read","params":{"uri":"mongodb://databases"},"jsonrpc":"2.0","id":1}
The server should respond with a list of databases in your MongoDB instance, for example:
{"result":{"contents":[{"uri":"mongodb://databases","text":"Databases (12):\n- admin (180.00 KB)\n- config (108.00 KB)\n- local (40.00 KB)\n- sample_airbnb (51.88 MB)\n- sample_analytics (9.46 MB)\n- sample_geospatial (980.00 KB)\n- sample_guides (40.00 KB)\n- sample_mflix (108.90 MB)\n- sample_restaurants (7.73 MB)\n- sample_supplies (968.00 KB)\n- sample_training (40.85 MB)\n- sample_weatherdata (2.69 MB)"}]},"jsonrpc":"2.0","id":1}
MongoDB Lens is now installed and ready to accept MCP requests.
If connecting to a MongoDB instance with a version < 4.0, the MongoDB Node.js driver used by the latest version of MongoDB Lens will not be compatible. Specifically, MongoDB Node.js driver versions 4.0.0 and above require MongoDB version 4.0 or higher.
To use MongoDB Lens with older MongoDB instances, you need to use a MongoDB Node.js driver version from the 3.x series (e.g. 3.7.4 which is compatible with MongoDB 3.6).
1. Clone the MongoDB Lens repository:<br>
git clone https://github.com/furey/mongodb-lens.git
1. Navigate to the cloned repository directory:<br>
cd /path/to/mongodb-lens
1. Modify
package.json:<br> "dependencies": {
...
- "mongodb": "^6.15.0", // Or whatever newer version is listed
+ "mongodb": "^3.7.4", // Or whatever 3.x version is compatible with your older MongoDB instance
...
}
1. Install Node.js dependencies:<br>
npm install
1. Start MongoDB Lens:<br>
node mongodb-lens.js mongodb://older-mongodb-instance
This will use the older driver version compatible with your MongoDB instance.
> [!NOTE]<br>
> You may also need to revert this commit to add back useNewUrlParser and useUnifiedTopology MongoDB configuration options.
The server accepts a MongoDB connection string as its only argument.
Example NPX usage:
npx -y mongodb-lens@latest mongodb://your-connection-string
MongoDB connection strings have the following format:
```txt
add-connection-alias
Add a new MongoDB connection alias.
aggregate-data
Execute aggregation pipelines.
analyze-query-patterns
Analyze live queries and suggest optimizations.
analyze-schema
Automatically infer collection schemas.
bulk-operations
Perform multiple operations efficiently (requires confirmation for destructive operations).
clear-cache
Clear memory caches to ensure fresh data.
collation-query
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-documents
Count documents matching specified criteria.
create-collection
Create new collections with custom options.
create-database
Create a new database with option to switch to it.
create-index
Create new indexes for performance optimization.
create-timeseries
Create time series collections for temporal data.
create-user
Create new database users with specific roles.
current-database
Show the current database context.
delete-document
Delete documents matching specified criteria (requires confirmation).
distinct-values
Extract unique values for any field.
drop-collection
Remove collections from the database (requires confirmation).
drop-database
Drop a database (requires confirmation).
drop-index
Remove indexes from collections (requires confirmation).
drop-user
Remove database users (requires confirmation).
explain-query
Analyze query execution plans.
export-data
Export query results in JSON or CSV format.
find-documents
Run queries with filters, projections, and sorting.
generate-schema-validator
Generate JSON Schema validators.
geo-query
Perform geospatial queries with various operators.
get-stats
Retrieve database or collection statistics.
gridfs-operation
Manage large files with GridFS buckets.
insert-document
Insert one or more documents into collections.
list-collections
Explore collections in the current database.
list-connections
View all available MongoDB connection aliases.
list-databases
View all accessible databases.
rename-collection
Rename existing collections (requires confirmation when dropping targets).
shard-status
View sharding configuration for databases and collections.
text-search
Perform full-text search across text-indexed fields.
transaction
Execute multiple operations in a single ACID transaction.
update-document
Update documents matching specified criteria.
use-database
Switch to a specific database context.
validate-collection
Check for data inconsistencies.
watch-changes
Monitor real-time changes to collections.
- add-connection-alias: Add a new MongoDB connection alias
- aggregate-data: Execute aggregation pipelines
- analyze-query-patterns: Analyze live queries and suggest optimizations
- analyze-schema: Automatically infer collection schemas
- bulk-operations: Perform multiple operations efficiently (requires confirmation for destructive operations)
- clear-cache: Clear memory caches to ensure fresh data
- collation-query: 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-documents: Count documents matching specified criteria
- create-collection: Create new collections with custom options
- create-database: Create a new database with option to switch to it
- create-index: Create new indexes for performance optimization
- create-timeseries: Create time series collections for temporal data
- create-user: Create new database users with specific roles
- current-database: Show the current database context
- delete-document: Delete documents matching specified criteria (requires confirmation)
- distinct-values: Extract unique values for any field
- drop-collection: Remove collections from the database (requires confirmation)
- drop-database: Drop a database (requires confirmation)
- drop-index: Remove indexes from collections (requires confirmation)
- drop-user: Remove database users (requires confirmation)
- explain-query: Analyze query execution plans
- export-data: Export query results in JSON or CSV format
- find-documents: Run queries with filters, projections, and sorting
- generate-schema-validator: Generate JSON Schema validators
- geo-query: Perform geospatial queries with various operators
- get-stats: Retrieve database or collection statistics
- gridfs-operation: Manage large files with GridFS buckets
- insert-document: Insert one or more documents into collections
- list-collections: Explore collections in the current database
- list-connections: View all available MongoDB connection aliases
- list-databases: View all accessible databases
- rename-collection: Rename existing collections (requires confirmation when dropping targets)
- shard-status: View sharding configuration for databases and collections
- text-search: Perform full-text search across text-indexed fields
- transaction: Execute multiple operations in a single ACID transaction
- update-document: Update documents matching specified criteria
- use-database: Switch to a specific database context
- validate-collection: Check for data inconsistencies
- watch-changes: Monitor real-time changes to collections
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mongodb lens": {
"env": {},
"args": [
"-y",
"mongodb-lens@latest",
"mongodb://your-connection-string"
],
"command": "/path/to/npx"
}
}
}
Linux
{
"env": [],
"args": [
"-y",
"mongodb-lens@latest",
"mongodb://your-connection-string"
],
"command": "/path/to/npx"
}
Macos
{
"env": [],
"args": [
"-y",
"mongodb-lens@latest",
"mongodb://your-connection-string"
],
"command": "/path/to/npx"
}
Windows
{
"env": [],
"args": [
"/c",
"npx",
"-y",
"mongodb-lens@latest",
"mongodb://your-connection-string"
],
"command": "cmd"
}
MongoDB Lensis a local Model Context Protocol (MCP) server with full featured access to MongoDB databases using natural language via LLMs to perform queries, run aggregations, optimize performance, and more.
- Quick Start
- Features
- Installation
- Configuration
- Client Setup
- Data Protection
- Tutorial
- Test Suite
- Disclaimer
- Support
- InstallMongoDB Lens
- ConfigureMongoDB Lens
- Set upyour MCP Client (e.g.Claude Desktop,Cursor, etc)
- Explore your MongoDB databases withnatural language queries
- add-connection-alias: Add a new MongoDB connection alias
- aggregate-data: Execute aggregation pipelines
- analyze-query-patterns: Analyze live queries and suggest optimizations
- analyze-schema: Automatically infer collection schemas
- bulk-operations: Perform multiple operations efficiently (requires confirmationfor destructive operations)
- clear-cache: Clear memory caches to ensure fresh data
- collation-query: 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-documents: Count documents matching specified criteria
- create-collection: Create new collections with custom options
- create-database: Create a new database with option to switch to it
- create-index: Create new indexes for performance optimization
- create-timeseries: Create time series collections for temporal data
- create-user: Create new database users with specific roles
- current-database: Show the current database context
- delete-document: Delete documents matching specified criteria (requires confirmation)
- distinct-values: Extract unique values for any field
- drop-collection: Remove collections from the database (requires confirmation)
- drop-database: Drop a database (requires confirmation)
- drop-index: Remove indexes from collections (requires confirmation)
- drop-user: Remove database users (requires confirmation)
- explain-query: Analyze query execution plans
- export-data: Export query results in JSON or CSV format
- find-documents: Run queries with filters, projections, and sorting
- generate-schema-validator: Generate JSON Schema validators
- geo-query: Perform geospatial queries with various operators
- get-stats: Retrieve database or collection statistics
- gridfs-operation: Manage large files with GridFS buckets
- insert-document: Insert one or more documents into collections
- list-collections: Explore collections in the current database
- list-connections: View all available MongoDB connection aliases
- list-databases: View all accessible databases
- [rename-collection: Rename existing collections (](https://github.com/search?type=code&q=repo%3Afurey%2Fmongodb-lens+%2Fserver%5C.tool%5C%28%5Cs*%27r
…
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





