Feedback

MongoDB MCP Server (MongoDB-MCP-Server)

@mongodb-js Claim

Basic information

Runtime
node
Version
2.1.0
Category
License
Apache-2.0
Transports
stdio
Author
mongodb-js
Submitted by
Community
Quality
65
Stars
1.1K

About MongoDB MCP Server

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

MongoDB MCP Server is a MCP server in the Databases category listed in the AddMCP.net directory, published by mongodb-js. It exposes 27 tools, including aggregate-db, aggregate, collection-indexes, collection-schema and more. Supported transport: stdio. Runtime: node. License: Apache-2.0. The repository has 1,076 GitHub stars. Source code is hosted on github.com. Related topics: mcp, mcp-server, mongodb, mongodb-atlas, mongodb-database.

Setup

{
    "mcpServers": {
        "MongoDB": {
            "command": "npx",
            "args": [
                "-y",
                "mongodb-mcp-server"
            ],
            "env": {
                "MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:[email protected]/myDatabase"
            }
        }
    }
}

MongoDB MCP Server (MongoDB-MCP-Server) config

Add this server to your MCP-compatible client using the configuration below.

{
    "mcpServers": {
        "MongoDB": {
            "command": "npx",
            "args": [
                "-y",
                "mongodb-mcp-server"
            ],
            "env": {
                "MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:[email protected]/myDatabase"
            }
        }
    }
}

MongoDB MCP Server (MongoDB-MCP-Server) tools

  • aggregate-db — Run an aggregation against a MongoDB database
    connectionId:string*, database:string*, pipeline:array*, responseBytesLimit:number
  • aggregate — Run an aggregation against a MongoDB collection
    connectionId:string*, database:string*, collection:string*, pipeline:array*, responseBytesLimit:number
  • collection-indexes — Describe the indexes for a collection
    connectionId:string*, database:string*, collection:string*
  • collection-schema — Describe the schema for a collection
    connectionId:string*, database:string*, collection:string*, sampleSize:number, responseBytesLimit:number
  • collection-storage-size — Gets the size of the collection
    connectionId:string*, database:string*, collection:string*
  • connect — Connect to a MongoDB instance 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. A connection with the id "preconfigured" already exists for the connection string the server was configured with — there is no need to call this tool to use it.
    connectionString:string*, connectionName:string
  • count — Gets the number of documents in a MongoDB collection using db.collection.count() and query as an optional filter parameter
    connectionId:string*, database:string*, collection:string*, query:object
  • create-collection — Creates a new collection in a database. If the database doesn't exist, it will be created automatically.
    connectionId:string*, database:string*, collection:string*
  • create-index — Create an index for a collection
    connectionId:string*, database:string*, collection:string*, name:string, definition:array*
  • db-stats — Returns statistics that reflect the use state of a single database
    connectionId:string*, database:string*
  • delete-many — Removes all documents that match the filter from a MongoDB collection
    connectionId:string*, database:string*, collection:string*, filter:object
  • disconnect — Close a MongoDB connection and revoke its connectionId. Disconnecting the "preconfigured" connection only closes it — it reconnects automatically on next use because the server configuration still declares it.
    connectionId:string*
  • drop-collection — Removes a collection or view from the database. The method also removes any indexes associated with the dropped collection.
    connectionId:string*, database:string*, collection:string*
  • drop-database — Removes the specified database, deleting the associated data files
    connectionId:string*, database:string*
  • drop-index — Drop an index for the provided database and collection.
    connectionId:string*, database:string*, collection:string*, indexName:string*, type:string*
  • explain — Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method
    connectionId:string*, database:string*, collection:string*, method:array*, verbosity:string
  • export — Export a query or aggregation results in the specified EJSON format.
    connectionId:string*, database:string*, collection:string*, exportTitle:string*, exportTarget:array*, jsonExportFormat:string
  • find — Run a find query against a MongoDB collection
    connectionId:string*, database:string*, collection:string*, filter:object, projection:object, limit:number, sort:object, responseBytesLimit:number
  • 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.
    connectionId:string*, database:string*, collection:string*, documents:array*
  • list-collections — List all collections for a given database
    connectionId:string*, database:string*
  • list-connections — List the active MongoDB connections and their connectionIds. Use this to discover the "preconfigured" connection or to find a connectionId established earlier.
    (no parameters)
  • list-databases — List all databases for a MongoDB connection
    connectionId:string*
  • mongodb-logs — Returns the most recent logged mongod events
    connectionId:string*, type:string, limit:number
  • rename-collection — Renames a collection in a MongoDB database
    connectionId:string*, database:string*, collection:string*, newName:string*, dropTarget:boolean
  • 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.
    connectionId:string*, database:string*, collection:string*, filter:object, update:object*, upsert:boolean
  • 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.
    (no parameters)
  • 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.
    query:string*, limit:number, dataSources:array

Overview

What is MongoDB MCP Server?

It is a Model Context Protocol server for interacting with MongoDB databases and MongoDB Atlas. It allows AI assistants to perform read‑only (or optionally write) database operations and manage Atlas resources using either a MongoDB connection string or Atlas API service account credentials.

How to use MongoDB MCP Server?

Requires Node.js v22.13 or later. Configure it in your MCP client (e.g., VS Code, Cursor, Claude Desktop) by running npx -y mongodb-mcp-server@latest with the --readOnly flag by default. Pass credentials via environment variables (MDB_MCP_CONNECTION_STRING or MDB_MCP_API_CLIENT_ID/MDB_MCP_API_CLIENT_SECRET). Docker images are also available.

Key features of MongoDB MCP Server

  • Supports MongoDB Atlas tools (API‑based) and database tools (driver‑based).
  • Provides MongoDB assistant tools for common help tasks.
  • Reads database schemas, collections, and indexes as resources.
  • Configurable via environment variables, command‑line arguments, or MCP client configuration.
  • Runs as a standalone service or inside a Docker container.
  • Defaults to read‑only mode; remove --readOnly to enable writes.

Use cases of MongoDB MCP Server

  • Query and explore MongoDB databases through a conversational AI assistant.
  • Manage Atlas clusters, projects, and API keys using service account credentials.
  • Retrieve database schemas and indexes for documentation or migration planning.
  • Deploy as a microservice on public clouds such as Azure.

Frequently asked questions

1 What are the prerequisites to run MongoDB MCP Server?

Node.js v22.13 or later is required. A MongoDB connection string or Atlas API service account credentials must be provided.

2 Is the server read‑only by default?

Yes. All configuration examples include the --readOnly flag. Remove it if you need write operations.

3 Can I run MongoDB MCP Server using Docker?

Yes. A Docker image mongodb/mongodb-mcp-server:latest is available. Pass environment variables via -e flags or through an MCP configuration file.

4 How do I pass credentials securely?

The README strongly recommends using environment variables (MDB_MCP_CONNECTION_STRING, MDB_MCP_API_CLIENT_ID, MDB_MCP_API_CLIENT_SECRET) instead of command‑line arguments to avoid exposing secrets in process lists or logs.

5 Which MCP clients are supported?

Configuration examples are provided for Windsurf, VS Code, Claude Desktop, Cursor, Copilot CLI, and Opencode CLI.

Comments

No comments yet

Be the first to share feedback about this listing. Sign in to leave a comment.

Sign In

Feedback 💬