Registry / database / mongodb-lens

mongodb-lens

JSON →
library9.1.4jsnpmunverified

MongoDB Lens v9.1.4 is a full-featured Model Context Protocol (MCP) server that provides natural language access to MongoDB databases via LLMs like Claude. It enables querying, aggregation, schema analysis, performance optimization, and data manipulation through MCP tools, resources, and prompts. The package is actively maintained with regular releases on npm and Docker. Key differentiators include a comprehensive set of tools (over 30), built-in data protection with confirmation for destructive operations, memory caching, and support for multiple connection aliases. It requires Node.js >=18 and the MongoDB driver.

npm install mongodb-lens
INSTALL
IMPORT
SIG · MONGODB-LENS
M
mongodb-lens
databasejavascriptv9.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MongoDBLensServer
import { MongoDBLensServer } from 'mongodb-lens'
const MongoDBLensServer = require('mongodb-lens')
ESM-only since v9. Requires 'type': 'module' in package.json or .mjs extension.
startServer
import { startServer } from 'mongodb-lens'
const { startServer } = require('mongodb-lens')
Default export also available: import startServer from 'mongodb-lens'
Configuration
import type { Configuration } from 'mongodb-lens'
const { Configuration } = require('mongodb-lens')
Type export, only available with TypeScript via type import.

Starts the MongoDB Lens MCP server with a MongoDB URI and allowed databases.

import { startServer } from 'mongodb-lens'; const config = { mongoUri: process.env.MONGO_URI ?? 'mongodb://localhost:27017', allowedDatabases: ['mydb'], port: 3000, }; startServer(config).then(server => { console.log('MongoDB Lens server started on port', server.port); }).catch(err => { console.error('Failed to start server:', err); });
Debug
Known issues
breakingIn v9, the package is ESM-only. CommonJS require() will fail.
fix
Use import syntax or set 'type': 'module' in package.json.
affects: >=9.0.0
gotchaThe server listens on port 3000 by default, which may conflict with other services.
fix
Set a custom port in the configuration object.
affects: >=0.0.0
gotchaDestructive operations (delete, update many) require explicit confirmation from the user; the tool will prompt via MCP.
fix
Ensure your MCP client supports user confirmation prompts.
affects: >=0.0.0
deprecatedThe 'add-connection-alias' tool is deprecated in favor of passing aliases in configuration.
fix
Define connection aliases in the configuration object instead.
affects: >=9.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mongodb-lens'
Package not installed or ESM/CJS mismatch.
fix
Run npm install mongodb-lens@latest and ensure you are using import syntax.
TypeError: startServer is not a function
Using default import incorrectly or CJS require.
fix
Use import { startServer } from 'mongodb-lens' or import startServer from 'mongodb-lens'.
Error: MongoParseError: Invalid connection string
Missing or malformed MONGO_URI environment variable.
fix
Set MONGO_URI to a valid MongoDB connection string, e.g., mongodb://localhost:27017/mydb
Upgrade
Version history
9.1.4latest on npm
Audit
Dependencies
@modelcontextprotocol/sdkrequiredMCP server implementation
mongodbrequiredMongoDB driver for database operations
Agent activity
6 hits · last 30 days
node
6
Resources
mongodb-lens — npm install mongodb-lens · libregistry