LABSCO 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
Build from source — git clone https://github.com/jonfreeland/mongodb-mcp
USE CASES
01
Working out what is in a collection
Infer the schema from real documents and sample a few before writing any query.
02
Answering a question with an aggregation
Run the pipeline with write stages blocked, so an analysis cannot turn into a mutation.
03
Finding things near a location
Query near a point, inside a polygon, or intersecting a geometry.
04
Explaining why a query is slow
Read the execution plan and index information alongside collection statistics.
BEFORE YOU INSTALL
What to know first
Requires
MONGODB_URI in your environment
Where it runs
Both documented clients run the server on your machine.
INSTALLATION
Connect your client
You clone and build this one yourself.
Server setup
TERMINAL
git clone https://github.com/jonfreeland/mongodb-mcp
cd mongodb-mcp
npm install
npm run buildMCP Clients
Claude Desktop
CLAUDE DESKTOP · JSON
{
"mcpServers": {
"mongodb": {
"command": "<YOUR_PATH_TO_MONGODB_SERVER>/build/index.js",
"env": {
"MONGODB_URI": "mongodb://<YOUR_DB_USER>:<YOUR_DB_PASSWORD>@<YOUR_DB_HOST>:<YOUR_DB_PORT>/<YOUR_DB_NAME>",
"MONGODB_DEFAULT_DATABASE": "<YOUR_MONGODB_DEFAULT_DATABASE>"
}
}
}
}<YOUR_PATH_TO_MONGODB_SERVER> is the full path of the mongodb-mcp folder you cloned (the build puts index.js in its build folder), MONGODB_URI is your connection string, and <YOUR_MONGODB_DEFAULT_DATABASE> the database to use when a query names none.
Cline
CLINE · JSON
{
"mcpServers": {
"mongodb": {
"command": "node",
"args": [
"<YOUR_PATH_TO_MONGODB_SERVER>/build/index.js"
],
"env": {
"MONGODB_URI": "mongodb://<YOUR_DB_USER>:<YOUR_DB_PASSWORD>@<YOUR_DB_HOST>:<YOUR_DB_PORT>/<YOUR_DB_NAME>",
"MONGODB_DEFAULT_DATABASE": "<YOUR_MONGODB_DEFAULT_DATABASE>"
}
}
}
}<YOUR_PATH_TO_MONGODB_SERVER> is the full path of the mongodb-mcp folder you cloned (the build puts index.js in its build folder), MONGODB_URI is your connection string, and <YOUR_MONGODB_DEFAULT_DATABASE> the database to use when a query names none.