ClaudeCodeMod

All shelves / MCP servers

Mongodb Mcp Server

mongodb-js/mongodb-mcp-server · 1k stars · TypeScript · Apache-2.0

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

Install

In your shell
npx -y mongodb-mcp-server@latest setup

These repos do not share one command. When an entry shows a command, it was copied as published. Check the repo's README before you run it.

Open the repo

Files

README.md

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

  • 🚀 Getting Started
  • Prerequisites
  • Manual Setup
  • 🛠️ Supported Tools
  • MongoDB Atlas Tools
  • MongoDB Database Tools
  • MongoDB Assistant Tools
  • 📄 Supported Resources
  • ⚙️ Configuration
  • Configuration Options
  • Atlas API Access
  • Configuration Methods
  • Environment Variables
  • Command-Line Arguments
  • MCP Client Configuration
  • Proxy Support
  • 🚀 Deploy on Public Clouds
  • Azure Cloud
  • 🤝 Contributing

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

When working with MongoDB Atlas, the recommended approach is to install the mongodb-atlas plugin for your AI agent, which handles OAuth authentication automatically.

For manual configuration, see the client-specific instructions for setting up the Atlas Remote MCP server with OAuth. Alternatively, you can connect using the mongodb-atlas-mcp-remote package with Service Account credentials — see the package README for setup instructions.

Note: You cannot authenticate to the remote MongoDB MCP server using a static API key over HTTP. You must either: - Use a client that supports the OAuth flow. - Use the mongodb-atlas-mcp-remote stdio server, which you can authenticate into using the static MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET environment variables.

To connect with the mongodb-atlas-mcp-remote stdio server using Service Account credentials, add it to your client's MCP configuration:

{
  "mcpServers": {
    "mongodb-atlas-mcp-remote": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "mongodb-atlas-mcp-remote@latest"],
      "env": {
        "MDB_MCP_API_CLIENT_ID": "$CLIENT_ID",
        "MDB_MCP_API_CLIENT_SECRET": "$SECRET"
      }
    }
  }
}

#### Option 3: Atlas API Credentials

Use your Atlas API Service Accounts credentials. Must follow all the steps in Atlas API Access section.

{
  "mcpServers": {
    "MongoDB": {
      "command": "npx",
      "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"],
      "env": {
        "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id",
        "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret"
      }
    }
  }
}

#### Option 4: Standalone Service using environment variables and command line arguments

You can source environment variables defined in a config file or explicitly set them like we do in the example below and run the server via npx.

# Set your credentials as environment variables first
export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id"

Facts

Kind
MCP server
Repo
mongodb-js/mongodb-mcp-server
Group
Uncategorized
Stars
1k
License
Apache-2.0
Language
TypeScript
Last push
2026-10-08
Forks
296
Topics
mcp, mcp-server, mongodb, mongodb-atlas, mongodb-database

More on this shelf

  1. 1Everythingmodelcontextprotocol/serversThis MCP server attempts to exercise all the features of the MCP protocol. It is not intended to be a useful server, but rather a test server for builders of MCP clients. It implements prompts, tools, resources, sampling, and more to showcase MCP capabilities.85.8k
  2. 2Fetchmodelcontextprotocol/serversA Model Context Protocol server that provides web content fetching capabilities. This server enables LLMs to retrieve and process content from web pages, converting HTML to markdown for easier consumption.85.8k
  3. 3Gitmodelcontextprotocol/serversA Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.85.8k
  4. 4Memorymodelcontextprotocol/serversA basic implementation of persistent memory using a local knowledge graph. This lets Claude remember information about the user across chats.85.8k
  5. 5Sequential Thinkingmodelcontextprotocol/serversAn MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.85.8k
  6. 6Timemodelcontextprotocol/serversA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.85.8k