MongoDB
The MCP MongoDB Server enables interaction with MongoDB databases through a standardized interface, allowing both read and write operations.
Read Operations: Query documents, execute aggregation pipelines, count documents, and get collection schema information.
Write Operations: Update documents, insert new documents, and create indexes (when not in read-only mode).
Smart ObjectId Handling: Convert between string IDs and MongoDB ObjectId with configurable modes.
Read-Only Mode: Protect against write operations in production environments.
Server Information: Retrieve MongoDB server details, including version and storage engine.
Collection Management: List available collections and inspect their schemas.
LLM Integration: Enhanced interaction with collection completions and schema inference.
Flexible Configuration: Set connection parameters via environment variables or command-line options.
Provides access to MongoDB databases, allowing LLMs to inspect collection schemas and execute MongoDB operations like queries, aggregations, updates, inserts, and creating indexes
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MongoDBshow me the schema for the users collection"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP MongoDB Server
A Model Context Protocol (MCP) server that lets AI assistants work with your MongoDB databases. It exposes your collections, infers their schemas, and runs queries, aggregations, and writes through a standard interface — so tools like Claude Desktop and Cursor can read and reason about your data.
Demo

Related MCP server: MongoDB MCP Server for LLMs
Why use it
Talk to your database in plain language — the assistant discovers your collections and their shape automatically.
Safe by default — turn on read-only mode to let an assistant explore without any risk of changing data.
Works everywhere — connects to standalone, replica set, sharded, and Atlas deployments, over plain or TLS connections.
Key Features
Read-Only Mode — blocks every write path (insert, update, index creation, and aggregation stages like
$out/$mergethat could modify data).Smart ObjectId Handling — configurable
auto/none/forceconversion of 24-character hex strings to ObjectIds.Schema Inference — automatic collection schema detection from document samples.
Query & Aggregation — full query and aggregation pipeline support, with optional
explainplans.Write Operations — insert, update, and index creation (when read-only mode is off).
Time Conversion — a
convertTimehelper turns Unix timestamps and date strings into UTC/GMT/ISO, so date queries stay unambiguous across timezones.Progress & Cancellation — long operations report progress and can be cancelled mid-flight.
Two Transports — run locally over stdio, or expose an HTTP endpoint for remote access.
Requirements
Node.js 20 or newer
Quick Start
Point the server at your database — no install step needed:
npx -y mcp-mongo-server mongodb://localhost:27017/mydatabaseExplore safely, without any chance of changing data:
npx -y mcp-mongo-server mongodb://localhost:27017/mydatabase --read-onlyUsage
Local (stdio)
This is the default, used by Claude Desktop, Cursor, and other local clients:
npx -y mcp-mongo-server "mongodb://user:pass@localhost:27017/mydatabase"Remote (HTTP)
Expose an HTTP endpoint at /mcp for remote or multi-client access:
npx -y mcp-mongo-server "mongodb://user:pass@localhost:27017/mydatabase" --transport http --port 3001By default, only requests without a browser Origin (CLIs, IDEs) and requests
from localhost are accepted; everything else is rejected with 403 to guard
against DNS-rebinding attacks. Allow specific browser origins with
--allowed-origins:
npx -y mcp-mongo-server "mongodb://..." --transport http --port 3001 --allowed-origins "https://app.example.com"Options
Flag | Description |
| Block all write operations |
| Allow aggregation |
| Allow server-side JavaScript operators |
|
|
| HTTP port (default |
| Comma-separated browser origins to allow in HTTP mode |
| Max HTTP request body size (default |
| Require |
Environment Variables
Variable | Description |
| MongoDB connection URI (alternative to the argument) |
| Enable read-only mode ( |
| Allow cross-database aggregation stages ( |
| Allow server-side JavaScript operators ( |
| HTTP port |
| Comma-separated browser origins to allow in HTTP mode |
| Max HTTP request body size (default |
| Bearer token required to access the HTTP endpoint |
Security
Database scope. The server operates on the database in your connection
string. Aggregation stages that reach another database ($out, $merge,
$lookup with an explicit db) are rejected by default, so a pipeline can't
quietly read from or write to databases you didn't point it at. Enable them
with --allow-cross-db if you need them.
Server-side JavaScript. The aggregation operators $function, $where,
and $accumulator run arbitrary JavaScript on the MongoDB server. They are
rejected by default; enable them with --allow-server-js if you trust the
pipelines being run.
Read-only mode blocks every write path, including aggregation stages that
write or run server-side JavaScript ($out, $merge, $function, $where,
$accumulator).
Least privilege. Application-level checks only go so far — the strongest guarantee comes from the database. Connect with a MongoDB user scoped to just the database you need, with read-only permissions when the assistant only needs to explore. That way the database itself enforces the boundary, as defense in depth.
Documentation
Integration Guide — Claude Desktop, Windsurf, Cursor, Docker
Available Tools — query, aggregate, update, insert, and more
Development — setup, scripts, and debugging
License
MIT — see LICENSE for details.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityFmaintenanceA Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.27175MIT
- Alicense-qualityDmaintenanceA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.272MIT
- Alicense-qualityDmaintenanceA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.27MIT
- AlicenseDqualityDmaintenanceA Model Context Protocol server that enables LLMs to interact with databases (currently MongoDB) through natural language, supporting operations like querying, inserting, deleting documents, and running aggregation pipelines.516MIT
Related MCP Connectors
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP (Model Context Protocol) server for Appwrite
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/kiliczsh/mcp-mongo-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server