A read-only Model Context Protocol (MCP) server for querying MongoDB databases, version 1.0.4, actively maintained. It exposes tools like list_databases, list_collections, list_indexes, run_aggregation, and run_aggregation_to_file via the MCP standard, allowing AI agents to inspect MongoDB schemas and run aggregation pipelines. Key differentiators: entirely read-only (rejects write stages $out, $merge), enforces a 50-second query timeout, and uses secondaryPreferred read preference for safety. Requires Node >=18 and a MongoDB connection string via MONGODB_URI environment variable. Published on npm, includes TypeScript types.
npm install mongodb-mcpNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to start the MongoDB MCP server via npx with a connection URI, and example configuration for Claude Desktop.
Use 'run_aggregation' for smaller result sets, or monitor for alternative output methods.
Ensure MONGODB_URI is exported before running the server: export MONGODB_URI='mongodb://...'
Do not include write stages in the pipeline array. Use run_aggregation for read-only queries.
Optimize pipelines or use run_aggregation_to_file for large result sets to avoid timeout.
Set the MONGODB_URI variable before running: export MONGODB_URI='mongodb://username:password@host:port/dbname'
Start mongod locally or correct the connection string in MONGODB_URI.
Remove $out or $merge stages from the pipeline.
Optimize the pipeline, add indexes, or use run_aggregation_to_file to write results to a file.