MongoDB Lens – a full-featured Model Context Protocol (MCP) server that lets LLMs query and manage MongoDB databases through a rich set of tools, prompts and resources.
https://github.com/furey/mongodb-lensStop writing MongoDB queries by hand. MongoDB Lens transforms your database into a conversational interface, letting you query, analyze, and manage MongoDB through natural language while maintaining the safety and precision your production data deserves.
You're already comfortable with MongoDB's query syntax, but switching between your LLM conversation and the mongo shell breaks your flow. Whether you're exploring a new dataset, debugging performance issues, or explaining database schemas to stakeholders, MongoDB Lens bridges that gap by bringing your entire database into your LLM's context.
This isn't about replacing your MongoDB skills—it's about extending them. Ask questions like "show me users who haven't logged in for 90 days" or "analyze the schema evolution in our events collection" and get immediate, actionable results without context switching.
40+ MongoDB Operations: Everything from basic queries to advanced aggregations, geospatial searches, index management, and performance analysis. No need to remember syntax for operations you rarely use.
Production-Grade Safety: Confirmation tokens for destructive operations, read-only user support, configurable operation limits, and selective tool disabling. Your data stays protected even when experimenting.
Natural Language Intelligence: The LLM understands MongoDB concepts and can suggest optimizations, explain query plans, and help design schemas based on your use patterns.
Zero Learning Curve: Works with your existing MongoDB setup—local instances, Atlas clusters, replica sets. No new infrastructure or migration required.
Database Exploration: "What's the schema structure of the user_events collection?" instantly gives you field analysis, data types, and sample documents—perfect for understanding unfamiliar datasets.
Performance Debugging: "Why is this query slow?" triggers execution plan analysis and index recommendations without diving into explain() output manually.
Schema Evolution: "Compare the users schema between staging and production" highlights structural differences that could cause deployment issues.
Data Quality Audits: "Find inconsistent date formats in the orders collection" or "Show me duplicate email addresses" helps maintain data integrity.
Ad-Hoc Analytics: "Group sales by region for Q4 and show the top 3 products in each" gets you business insights without building dashboards.
The fastest path is NPX—no installation required:
# Connect to local MongoDB
npx -y mongodb-lens@latest
# Or specify your connection string
npx -y mongodb-lens@latest mongodb://your-connection-string
Then configure your MCP client (like Claude Desktop) to use MongoDB Lens:
{
"mcpServers": {
"mongodb-lens": {
"command": "/path/to/npx",
"args": ["-y", "mongodb-lens@latest"]
}
}
}
Docker users get the same simplicity:
docker run --rm -i --network=host furey/mongodb-lens
MongoDB Lens assumes you're working with real data that matters. Destructive operations require explicit confirmation through time-limited tokens. Want to drop a collection? You'll get a 4-digit code that expires in 5 minutes—no accidents from typos or misunderstood prompts.
Need read-only access? Configure a MongoDB user with read permissions, or disable write tools entirely through the config file. You can even run against database backups for safe experimentation.
Smart Schema Analysis: Automatically infers collection schemas from sample data, shows field usage patterns, and suggests validation rules.
Index Optimization: Analyzes query patterns and recommends indexes that actually match your workload.
Multi-Database Management: Switch between development, staging, and production databases using named aliases.
Aggregation Pipeline Builder: Constructs complex aggregations through conversational prompts instead of nested JSON.
Real-Time Monitoring: Watch collection changes, analyze performance metrics, and get health reports on command.
Start simple with defaults, then customize everything through a JSON config file. Control connection pooling, cache behavior, security settings, and which tools are available. Environment variables override config settings for different deployment environments.
Multiple MongoDB connections? Define aliases in your config and switch between them by name: "Connect to staging" or "Switch to the analytics cluster."
Works with any MCP-compatible client. Claude Desktop gets you started immediately, but you can integrate with custom applications, CI/CD pipelines, or internal tools that need database insights.
The comprehensive test suite covers all tools and operations, so you can rely on consistent behavior across MongoDB versions and deployment types.
MongoDB Lens respects your existing MongoDB infrastructure while making it more accessible. Your schemas, indexes, and data remain unchanged—you just get a more intuitive interface for working with them.
Whether you're debugging production issues, exploring new datasets, or explaining database structure to team members, MongoDB Lens transforms database administration from a context switch into a conversation.