mongodb-lens
🍃🔎 MongoDB Lens: Full Featured MCP Server for MongoDB Databases
claude mcp add --transport stdio furey-mongodb-lens npx -y mongodb-lens \ --env MONGO_DB="Default database to connect to (optional)" \ --env LOG_LEVEL="debug|info|warn|error (optional)" \ --env MONGO_URI="MongoDB connection URI (e.g., mongodb://user:pass@host:port/db)" \ --env OPENAI_API_KEY="OpenAI API key for LLM (optional if using local/alternative LLMs)"
How to use
MongoDB Lens is an MCP server that exposes MongoDB operations through natural language prompts and a suite of built‑in tools. It integrates with LLMs to translate user intent into precise MongoDB actions such as finding documents, running aggregations, creating indexes, and analyzing query performance. The server ships with a broad set of tools (e.g., find-documents, aggregate-data, explain-query, insert-document, update-document, delete-document, create-index, get-stats, and more) that you can invoke via the MCP client to perform common database tasks without writing raw MongoDB queries. Connect your MCP client to the mongodb-lens server, then use conversational prompts or structured tool invocations to perform database work with safety checks and helpful prompts when destructive actions are requested.
How to install
Prerequisites:
- Node.js and npm (or just npm if using npx).
- Access to a MongoDB instance (local or remote).
Installation steps:
-
Ensure Node.js and npm are installed. Verify: node -v npm -v
-
Use npx to run the MongoDB Lens server directly from npm registry (no global install required): npx -y mongodb-lens
-
Alternatively, install locally or globally for repeated use: npm install -g mongodb-lens mongodb-lens --help
-
Configure environment variables (examples):
- MONGO_URI=mongodb://localhost:27017
- MONGO_DB=mydb
- OPENAI_API_KEY=sk-...
-
Start the server (if using local install): mongodb-lens
-
Connect a compatible MCP client (e.g., Claude Desktop, Cursor) using the provided server endpoint and API credentials.
Additional notes
Tips and common issues:
- Ensure your MongoDB instance is accessible from the host running MongoDB Lens (check network ACLs and firewall rules).
- If you encounter authentication errors, verify MONGO_URI contains correct credentials or set MONGO_URI and MONGO_DB explicitly.
- When using destructive operations (delete-document, drop-collection, drop-database, etc.), the tools require explicit confirmation from the MCP client or prompt for safety checks. Enable that flow in your client configuration.
- If your LLM requires more guidance, provide tailored prompts or system messages to steer the tool usage toward safe operations and preferred data handling.
- For production deployments, consider running behind a reverse proxy, enabling TLS, and rotating API keys regularly.
- Review the available tools in the README or repository to understand capabilities and how to compose requests.
Related MCP Servers
Remote
A type-safe solution to remote MCP communication, enabling effortless integration for centralized management of Model Context.
openapi
OpenAPI definitions, converters and LLM function calling schema composer.
short-url
简单易用的短链接生成工具,完全开源、免费、无需登录,可私有化部署,链接永久有效!
the-academy
A Socratic dialogue engine for AI agents.
vscode-context
MCP Server to Connect with VS Code IDE
Email MCP server with full IMAP + SMTP support — read, search, send, manage, and organize email from any AI assistant via the Model Context Protocol