# MongoDB — MCP Server

> Query collections, run aggregations and inspect schemas with natural language.

**Source:** https://mcpplaygroundonline.com/mcp-servers/mongodb  
**Transport:** stdio  
**Requires auth:** Yes

---

## What it does

MongoDB MCP wraps the MongoDB Node.js driver as a set of MCP tools. Models can list databases and collections, query documents with filter expressions derived from natural language, run aggregation pipelines for analytics, insert or update documents (with confirmation), inspect indexes, and describe collection schemas by sampling documents. It runs as a local stdio process configured with your connection URI — no cloud account required beyond your existing MongoDB setup. The server is open source under the Apache 2.0 license and published on npm as @mongodb-js/mongodb-mcp-server.

## Tools exposed

- find — query documents by filter, projection and sort
- aggregate — run multi-stage aggregation pipelines
- insertOne / insertMany — insert documents with confirmation
- updateOne / updateMany — update documents matching a filter
- listCollections / listDatabases — enumerate databases and collections
- createIndex / listIndexes — manage and inspect collection indexes

## Example queries you can run

- "List all collections in the production database and their document counts."
- "Find the 10 most recent orders with status "pending" and total > $500."
- "Run an aggregation to show total revenue by product category for this month."
- "Show me the schema of the "users" collection by sampling 20 documents."

## Details

- **Recommended model:** anthropic/claude-sonnet-4.5 — Claude Sonnet 4.5 generates correct aggregation pipelines and multi-step query logic reliably. Use Haiku for simple find queries to keep costs low.
- **Transport:** stdio
- **Authentication:** Required — MongoDB connection URI (mongodb:// or mongodb+srv://). Supports Atlas, replica sets and local instances. Use a read-only user for safety.
- **Official source:** [mongodb-js/mongodb-mcp-server on GitHub](https://github.com/mongodb-js/mongodb-mcp-server)

## Frequently asked questions

### What is the MongoDB MCP server?

It is an official open-source MCP server from MongoDB, Inc. that lets AI models query and manage MongoDB databases through natural language. You give it a connection URI and it exposes find, aggregate, insert, update and schema-inspection tools to any MCP-compatible AI client.

### Does it work with MongoDB Atlas?

Yes. Paste your Atlas connection string (mongodb+srv://...) as the connection URI. It also works with self-hosted replica sets, standalone instances and local development servers on mongodb://localhost:27017.

### Is it safe to connect a production database?

Create a dedicated read-only MongoDB user and scope it to only the databases the agent needs. Never use an admin or atlas admin credential. For extra safety, point the agent at a staging replica during initial setup.

### Can the AI agent modify my data?

Yes — insertOne, updateOne and deleteOne tools are available. The server asks for confirmation before writes, and you can restrict it to a read-only user at the database level to make mutation impossible.

### How does MongoDB MCP compare to the Postgres MCP server?

MongoDB MCP speaks the MongoDB query language (BSON filters, aggregation pipelines) while Postgres MCP generates SQL. Both let AI models query your data in natural language — choose based on which database your application uses.

---

_Test this server across 40+ models on MCP Playground: https://mcpplaygroundonline.com/mcp-servers/mongodb — free, no install._
