Airsc is free for everyone. If it helps you, support it with $2–$20.

Support
MCP serverCautionDatabase & backendBeginner friendly Verified live

mongodb-mcp-server

mongodb-js · mongodb-js/mongodb-mcp-server

This MCP server enables AI agents to connect and interact with MongoDB databases and MongoDB Atlas Clusters, offering both direct marketplace plugins and local server setup options.

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

1.1k stars296License: Apache-2.0Updated 13 days ago0 opens

Preview

▍

What you can do with it

  • Allow your AI agent to query and manage data in a MongoDB Atlas database via a marketplace plugin.
  • Set up a local MCP server to enable AI agents to interact with a self-managed MongoDB deployment.
  • Integrate database operations directly into your agent's coding workflow for data-driven applications.

Verified live · 27 tools

We started this MCP server in an isolated sandbox and it exposed these tools:

  • aggregate-db

    Run an aggregation against a MongoDB database

  • aggregate

    Run an aggregation against a MongoDB collection

  • 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 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.

  • 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.

npx -y mongodb-mcp-server@latest · 08/10/2026

Safety check

Caution

Usable, but read the notes first.

  • ●Reads credential files (SSH keys, cloud or npm tokens).skills/mongodb-mcp-v3-migration/SKILL.md

Automated scan of the repo files. Always review code you run.

From the README

MongoDB MCP Server

A Model Context Protocol server for interacting with MongoDB Databases and MongoDB Atlas.

Quick Start

Using the official MongoDB plugins for AI agents

MongoDB MCP Server comes bundled with the official MongoDB plugins for AI agents. The following plugins are available:

mongodb-atlas — connects to the MongoDB-hosted Atlas MCP server over OAuth. This does not require you to run anything locally, and is the recommended way to connect to MongoDB Atlas from your AI agent:

  • Cursor: marketplace
  • VSCode: Open the Extensions view (⇧⌘X / Ctrl+Shift+X), search for @agentPlugins, and install mongodb-atlas.
  • Claude: marketplace
  • Codex: Open /plugins and install mongodb-atlas.
  • GitHub Copilot CLI: Run copilot plugin install mongodb-atlas.
  • Grok: Open /marketplace in Grok Build and install mongodb-atlas.

mongodb — runs the MongoDB MCP server locally and connects to any self-managed deployment:

  • Cursor: marketplace
  • Claude: marketplace
  • Gemini: marketplace
  • Codex: Run codex plugin marketplace add mongodb/agent-skills, then open /plugins and install mongodb.
  • GitHub Copilot CLI: Run copilot plugin install mongodb.
  • Grok: Open /marketplace in Grok Build and install mongodb.

Using the setup script

You can manually set up the local MCP server by running the following command:

npx -y mongodb-mcp-server@latest setup

This will guide you through an interactive setup process, including configuring your MongoDB connection string or Atlas API credentials.

For more advanced setup options, see the Manual Setup section below.

Using the MongoDB MCP Server setup skill

You can add and use the MongoDB MCP Server setup skill to configure your local MCP server using an AI agent.

npx skills add https://github.com/mongodb/agent-skills --skill mongodb-mcp-setup

Using manual configuration

See Manual Setup for instructions on how to manually configure the MongoDB MCP Server.

📚 Table of Contents

Prerequisites

[!NOTE] Node 20.x support is deprecated and will be removed in a future release. Please upgrade to Node 22.13 or later. See https://nodejs.org/en/blog/migrations/v20-to-v22 for migration details.

  • Node.js

    • At least v22.13.0. Check with node -v.
  • A MongoDB connection string or Atlas API credentials.

    • Service Accounts Atlas API credentials are required to use the Atlas tools. You can create a service account in MongoDB Atlas and use its credentials for authentication. See Atlas API Access for more details.
    • If you have a MongoDB connection string, you can use it directly to connect to your MongoDB instance.

Manual Setup

🔒 Security Recommendation 1: When using Atlas API credentials, be sure to assign only the minimum required permissions to your service account. See Atlas API Permissions for details.

🔒 Security Recommendation 2: For enhanced security, we strongly recommend using environment variables to pass sensitive configuration such as connection strings and API credentials instead of command line arguments. Command line arguments can be visible in process lists and logged in various system locations, potentially exposing your secrets. Environment variables provide a more secure way to handle sensitive information.

Most MCP clients require a configuration file to be created or modified to add the MCP server.

Note: The configuration file syntax can be different across clients. Please refer to the following links for the latest expected syntax:

Default Safety Notice: All examples below include --readOnly by default to ensure safe, read-only access to your data. Remove --readOnly if you need to enable write operations.

Option 1: Connection String

You can pass your connection string via environment variables, make sure to use a valid username and password.

{
  "mcpServers": {
    "MongoDB": {
      "command": "npx",
      "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"],
      "env": {
        "MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase"
      }
    }
  }
}

NOTE: The connection string can be configured to connect to any MongoDB cluster, whether it's a local instance or an Atlas cluster.

Option 2: Connect to the MongoDB Atlas-Managed MCP Server

View source on GitHub