# mongodb-mcp-server [Official] [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/mongodb-js/mongodb-mcp-server  
**GitHub Stars:** 1164  
**npm Downloads (last month):** 637581  
**Views:** 2  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/mongodb-mcp-server

## Description
A Model Context Protocol server to connect to MongoDB databases and MongoDB Atlas Clusters.

## Tools
Capabilities this server exposes over MCP:

- **aggregate** — Run an aggregation against a MongoDB collection
- **aggregate-db** — Run an aggregation against a MongoDB database
- **collection-indexes** — Describe the indexes for a collection
- **collection-schema** — Describe the schema for a collection
- **collection-storage-size** — Gets the size of the collection
- **connect** — Connect to a MongoDB instance
- **count** — Gets the number of documents in a MongoDB collection using db.collection.count() and query as an optional filter parameter
- **create-collection** — Creates a new collection in a database. If the database doesn't exist, it will be created automatically.
- **create-index** — Create an index for a collection
- **db-stats** — Returns statistics that reflect the use state of a single database
- **delete-many** — Removes all documents that match the filter from a MongoDB collection
- **disconnect** — Close a MongoDB connection and revoke its connectionId.
- **drop-collection** — Removes a collection or view from the database. The method also removes any indexes associated with the dropped collection.
- **drop-database** — Removes the specified database, deleting the associated data files
- **drop-index** — Drop an index for the provided database and collection.
- **explain** — Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method. Pipelines with $out or $merge stages are not accepted, because explain never writes.
- **export** — Export a query or aggregation results in the specified EJSON format.
- **find** — Run a find query against a MongoDB collection
- **insert-many** — Insert an array of documents into a MongoDB collection. If the list of documents is above com.mongodb/maxRequestPayloadBytes, consider inserting them in batches.
- **list-collections** — List all collections for a given database
- **list-connections** — List the active MongoDB connections and their connectionIds. Use this to find a connectionId established earlier.
- **list-databases** — List all databases for a MongoDB connection
- **mongodb-logs** — Returns the most recent logged mongod events
- **rename-collection** — Renames a collection in a MongoDB database
- **update-many** — Updates all documents that match the specified filter for a collection. If the list of documents is above com.mongodb/maxRequestPayloadBytes, consider updating them in batches.
- **atlas-connect-cluster** — Connect to MongoDB Atlas cluster and get back a connectionId to pass to the other MongoDB tools. Each call establishes a new, independent connection — multiple connections can be active at the same time.
- **atlas-create-access-list** — Allow Ip/CIDR ranges to access your MongoDB Atlas clusters.
- **atlas-create-cluster** — Create a MongoDB Atlas cluster (M10–M80, replica set or single shard). Compute autoscaling is enabled by default: min instance size is set to the selected instance size, max is set two tiers above. Disk autoscaling is always enabled. Encryption at rest with customer-managed keys (CMK) is supported,…
- **atlas-create-db-user** — Create an MongoDB Atlas database user
- **atlas-create-free-cluster** — Create a free MongoDB Atlas cluster
- **atlas-create-project** — Create a MongoDB Atlas project
- **atlas-get-performance-advisor** — Get MongoDB Atlas performance advisor recommendations and suggestions, which includes the operations: suggested indexes, drop index suggestions, schema suggestions, and a sample of the most recent (max 50) slow query logs
- **atlas-get-regions** — List supported MongoDB Atlas regions for a cloud provider.
- **atlas-inspect-access-list** — Inspect Ip/CIDR ranges with access to your MongoDB Atlas clusters.
- **atlas-inspect-cluster** — Inspect metadata of a MongoDB Atlas cluster
- **atlas-list-alerts** — List triggered alerts for a MongoDB Atlas project. These are alerts Atlas has raised, not the alert configurations that define them. Defaults to OPEN alerts; set status to TRACKING or CLOSED to see others.
- **atlas-list-clusters** — List MongoDB Atlas clusters
- **atlas-list-db-users** — List MongoDB Atlas database users
- **atlas-list-orgs** — List MongoDB Atlas organizations
- **atlas-list-projects** — List MongoDB Atlas projects.
- **atlas-load-sample-dataset** — Load a MongoDB sample dataset into an Atlas cluster, or check the status of a previously-initiated load. To start a new load, provide `clusterName` — the load runs asynchronously and the response includes a `jobId` and initial state. To check progress, call this tool again with `jobId` (sample data…
- **atlas-pause-resume-cluster** — Pause or resume a dedicated (M10+) MongoDB Atlas cluster.
- **atlas-streams-build** — Create Atlas Stream Processing resources. Use this tool for 'set up a Kafka pipeline', 'create a workspace', 'add a connection', or 'deploy a processor'. Use resource='workspace' to create a new workspace (specify cloud provider, region, and tier). Use resource='connection' to add a data source or…
- **atlas-streams-discover** — Discover and inspect Atlas Stream Processing resources. Also use for 'why is my processor failing', 'what workspaces do I have', 'show processor stats', or 'check processor health'. Use 'list-workspaces' to see all workspaces in a project. Use inspect actions for details on a specific resource. Use…
- **atlas-streams-manage** — Manage Atlas Stream Processing resources: start/stop processors, modify pipelines, update configurations. Also use for 'change the pipeline', 'scale up my processor', or 'update my workspace tier'. Common workflow: action='stop-processor' → action='modify-processor' → action='start-processor'. Use…
- **atlas-streams-teardown** — Delete Atlas Stream Processing resources. Also use for 'remove my workspace', 'disconnect a source', 'delete all processors', or 'clean up my streams environment'. Performs basic safety checks before deletion: summarizes counts of processors and connections, highlights connections referenced by pro…
- **atlas-upgrade-cluster** — Upgrade or scale a MongoDB Atlas cluster. Free and Flex clusters can be upgraded to Flex or M10 Dedicated. Dedicated clusters can be scaled to a different instance size, and compute autoscaling settings can be updated. When scaling a Dedicated cluster, at least one of targetTier, computeAutoScaling…
- **atlas-local-connect-deployment** — Connect to a MongoDB Atlas Local deployment and get back a connectionId to pass to the other MongoDB tools
- **atlas-local-create-deployment** — Create a MongoDB Atlas local deployment. Default image is latest. When the user does not specify an image tag, inform them that latest is used by default and provide this link for more information: https://hub.docker.com/r/mongodb/mongodb-atlas-local
- **atlas-local-delete-deployment** — Delete a MongoDB Atlas local deployment
- **atlas-local-list-deployments** — List MongoDB Atlas local deployments
- **list-knowledge-sources** — List available data sources in the MongoDB Assistant knowledge base. Use this to explore available data sources or to find search filter parameters to use in search-knowledge.
- **search-knowledge** — Search for information in the MongoDB Assistant knowledge base. This includes official documentation, curated expert guidance, and other resources provided by MongoDB. Supports filtering by data source and version.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "mongodb-mcp-server": {
    "command": "npx",
    "args": ["-y","mongodb-mcp-server@latest"],
    "env": {
      "MDB_MCP_CONNECTION_STRING": ""
    }
  }
}
```

**Requires environment variables:** `MDB_MCP_CONNECTION_STRING` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What mongodb-mcp-server does

mongodb-mcp-server gives AI agents an MCP interface to MongoDB databases and MongoDB Atlas. It supports both data-oriented work and administrative operations. Agents can inspect databases, collections, indexes, schemas, storage usage, query plans, and server logs, then use separate tools to insert, update, delete, rename, or remove data structures.

Atlas-specific tools cover connecting to a cluster, creating free or paid clusters, adding database users, and configuring IP or CIDR access ranges. The cluster creation tool supports M10 through M80 deployments, including replica sets and single-shard clusters. Atlas API access requires service-account credentials with appropriate permissions.

## How it works

The server establishes MongoDB connections and returns a connection identifier for subsequent operations. Agents can list active connections, discover databases and collections, and close a connection when finished. Atlas connections are independent, so multiple Atlas connections can remain active at once.

Database tools accept collection names, filters, documents, and aggregation definitions as appropriate. Query and aggregation results can be exported in EJSON. The `explain` operation reports execution statistics for the query plan selected by MongoDB's optimizer, which helps investigate query behavior and index usage.

Operations that can change or remove data include inserts, updates, deletes, index creation and removal, collection and database drops, and collection renaming. Review generated arguments carefully before allowing destructive operations.

## Setup and configuration

Node.js 22.13.0 or later is required; support for Node.js 20 is deprecated. The simplest installation path is the package's setup command:

```bash
npx -y mongodb-mcp-server@latest setup
```

The interactive setup guides configuration of a MongoDB connection string or Atlas API credentials. A local MCP client can also launch the package directly with `npx`; the VS Code installation example passes the connection string through `MDB_MCP_CONNECTION_STRING` and starts the server in read-only mode.

Most clients require an MCP configuration entry. Store connection strings and Atlas credentials in environment variables rather than command-line arguments, since command-line values may appear in process listings or logs. Atlas tools require MongoDB Atlas service-account API credentials, and those accounts should have only the permissions needed for the intended tasks.

Official plugins are available for MongoDB Atlas and for the local MongoDB server in clients including Cursor, VS Code, Claude, Gemini CLI, and Codex. The Atlas plugin connects to MongoDB's hosted Atlas MCP server over OAuth and does not require a local process.

## Tools and capabilities

- Query collections with `find`, count matching documents, and run collection or database aggregations.
- Inspect collection schemas, indexes, storage size, database statistics, and recent `mongod` events.
- Create, update, insert, or delete MongoDB documents.
- Create, drop, and inspect indexes; create, drop, and rename collections; or drop databases.
- List databases, collections, and active connections, then connect or disconnect as needed.
- Export query or aggregation output in EJSON.
- Create Atlas clusters, including free clusters, database users, and network access entries.

Large insert and update payloads may need to be divided into batches when they exceed MongoDB's request-payload limit.

## Limitations and notes

The server can perform destructive database and Atlas administration actions, so client permissions and service-account roles should be chosen carefully. Atlas cluster creation enables compute autoscaling by default, with the minimum set to the selected tier and the maximum set two tiers higher; disk autoscaling is enabled as well. Encryption at rest with customer-managed keys is supported for the relevant Atlas cluster configuration.

A MongoDB connection string is suitable for connecting to a MongoDB instance. Atlas administration tools instead require Atlas API service-account credentials, while Atlas data operations begin with an Atlas cluster connection that supplies a connection ID for other database tools.

_Full upstream README: https://allmcps.com/mcp/mongodb-mcp-server/readme_

