Labsco
MCP SERVER

MongoDB

by jonfreeland

Explore and query MongoDB from an assistant with no write path at all — including geospatial, text search and execution plans.

NoSQL, Graph & Key-Value Stores
Summary
Read-only by design, and it checks the pipeline for you.

An aggregation pipeline is the obvious hole in "read-only" — `$out` and `$merge` write — so validating stages before execution is the detail that makes the claim hold. The other thing worth knowing is that schema inference comes from sampling documents, which is exactly what you want on a collection nobody documented: the model gets the real shape of the data instead of guessing field names.

What it is

A read-only MongoDB server. It lists databases and collections, infers schemas from sample documents, runs queries and aggregations, and refuses write stages in a pipeline rather than trusting the caller.

What you get
  • Exploration: list databases and collections, and infer a collection's schema and data types from sampled documents
  • Querying with filtering, projection, sorting and limiting; aggregation pipelines run with safety validation that blocks write stages
  • Full-text search on collections that have a text index
  • Geospatial queries — near a point, within a polygon, or intersecting a geometry
  • Document operations: count, sample random documents, fetch by ID; plus distinct values and field distributions
  • Collection statistics, index information and query execution plans for performance work
  • Results export as JSON or CSV, and come back with visualization hints based on what is in them
Requirements

Built from source with `npm install` and `npm run build`, then pointed at your database with MONGODB_URI; MONGODB_DEFAULT_DATABASE sets the default when a query does not name one. Network access to the MongoDB server and read permissions on the target databases. Use a read-only MongoDB user — the server is read-only by design, and a read-only account makes that structural.

Setup effort

One command plus a key — claude mcp add mongo-server /path/to/mongodb-mcp/build/index.js -e "MONGODB_URI=mongodb://user@password:27017/dbname?authSource=authDbName" -e MONGO_DEFAULT_DATABASE=dbname, then supply credentials