# mongodb-lens

> MCP Server

MongoDB Lens is a local Model Context Protocol server that enables natural language interaction with MongoDB databases. It allows users to perform queries, run aggregations, and optimize performance using LLMs.

## Overview

- **Category:** Database
- **Language:** JavaScript
- **Stars:** 205
- **Forks:** 1
- **Owner:** furey
- **GitHub:** https://github.com/furey/mongodb-lens
- **Homepage:** https://www.npmjs.com/package/mongodb-lens
- **Created:** 2025-03-09T05:39:54+00:00
- **Updated:** 2025-03-28T21:38:45+00:00
- **Source:** https://model-context-protocol.com/servers/mongodb-natural-language-mongodb-database-queries

## Setup

## Setup

1.  Install MongoDB Lens using NPX, Docker Hub, Node.js from Source, or Docker from Source.
2.  Configure MongoDB Lens by setting the MongoDB connection string, using a config file, or environment variables.
3.  Set up your MCP Client (e.g., Claude Desktop, Cursor) by configuring the connection to MongoDB Lens.
4.  Explore your MongoDB databases with natural language queries.

## Tools

## Available Tools

1.  `aggregate-data`: Execute aggregation pipelines.
2.  `analyze-query-patterns`: Analyze live queries and suggest optimizations.
3.  `analyze-schema`: Automatically infer collection schemas.
4.  `bulk-operations`: Perform multiple operations efficiently.
5.  `collation-query`: Find documents with language-specific collation rules.
6.  `compare-schemas`: Compare schemas between two collections.
7.  `connect-mongodb`: Connect to a different MongoDB URI.
8.  `connect-original`: Connect back to the original MongoDB URI used at startup.
9.  `count-documents`: Count documents matching specified criteria.
10. `create-collection`: Create new collections with custom options.
11. `create-database`: Create a new database with option to switch to it.
12. `create-index`: Create new indexes for performance optimization.
13. `create-timeseries`: Create time series collections for temporal data.
14. `create-user`: Create new database users with specific roles.
15. `current-database`: Show the current database context.
16. `delete-document`: Delete documents matching specified criteria.
17. `distinct-values`: Extract unique values for any field.
18. `drop-collection`: Remove collections from the database.
19. `drop-database`: Drop a database.
20. `drop-index`: Remove indexes from collections.
21. `drop-user`: Remove database users.
22. `explain-query`: Analyze query execution plans.
23. `export-data`: Export query results in JSON or CSV format.
24. `find-documents`: Run queries with filters, projections, and sorting.
25. `generate-schema-validator`: Generate JSON Schema validators.
26. `geo-query`: Perform geospatial queries with various operators.
27. `get-stats`: Retrieve database or collection statistics.
28. `gridfs-operation`: Manage large files with GridFS buckets.
29. `list-collections`: Explore collections in the current database.
30. `list-connections`: View all available MongoDB connection aliases.
31. `list-databases`: View all accessible databases.
32. `map-reduce`: Run MapReduce operations for complex data processing.
33. `modify-document`: Insert or update specific documents.
34. `rename-collection`: Rename existing collections.
35. `shard-status`: View sharding configuration for databases and collections.
36. `text-search`: Perform full-text search across text-indexed fields.
37. `transaction`: Execute multiple operations in a single ACID transaction.
38. `use-database`: Switch to a specific database context.
39. `validate-collection`: Check for data inconsistencies.
40. `watch-changes`: Monitor real-time changes to collections.
41. `collection-indexes`: Get index information for a collection.
42. `collection-schema`: Get schema information for a collection.
43. `collection-stats`: Get performance statistics for a collection.
44. `collection-validation`: Get validation rules for a collection.
45. `collections`: List of collections in the current database.
46. `database-triggers`: Get database change streams and event triggers configuration.
47. `database-users`: Get database users and roles in the current database.
48. `databases`: List of all accessible databases.
49. `performance-metrics`: Get real-time performance metrics and profiling data.
50. `replica-status`: Get replica set status and configuration.
51. `server-status`: Get server status information.
52. `stored-functions`: Get stored JavaScript functions in the current database.
53. `aggregation-builder`: Step-by-step creation of aggregation pipelines.
54. `backup-strategy`: Customized backup and recovery recommendations.
55. `data-modeling`: Expert advice on MongoDB schema design for specific use cases.
56. `database-health-check`: Comprehensive database health assessment and recommendations.
57. `index-recommendation`: Get personalized index suggestions based on query patterns.
58. `migration-guide`: Step-by-step MongoDB version migration plans.
59. `mongo-shell`: Generate MongoDB shell commands with explanations.
60. `multi-tenant-design`: Design MongoDB multi-tenant database architecture.
61. `query-builder`: Interactive guidance for constructing MongoDB queries.
62. `query-optimizer`: Optimization recommendations for slow queries.
63. `schema-analysis`: Detailed collection schema analysis with recommendations.
64. `schema-versioning`: Manage schema evolution in MongoDB applications.
65. `security-audit`: Database security analysis and improvement recommendations.
66. `sql-to-mongodb`: Convert SQL queries to MongoDB aggregation pipelines.
