Airsc miễn phí cho tất cả. Nếu nó giúp bạn, hãy ủng hộ $2–$20.

Ủng hộ
MCP serverCẩn thậnDatabase & backendDễ cho người mới Đã chạy thử thật

mongodb-mcp-server

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

MCP server này cho phép các tác nhân AI kết nối và tương tác với cơ sở dữ liệu MongoDB và MongoDB Atlas Clusters, cung cấp cả plugin trực tiếp từ marketplace và tùy chọn thiết lập máy chủ cục bộ.

Một Model Context Protocol server để kết nối với các cơ sở dữ liệu MongoDB và MongoDB Atlas Clusters.

1.1k sao296Giấy phép: Apache-2.0Cập nhật 13 ngày trước0 lượt mở

Xem trước

▍

Bạn có thể làm gì với nó

  • Cho phép tác nhân AI của bạn truy vấn và quản lý dữ liệu trong cơ sở dữ liệu MongoDB Atlas thông qua plugin từ marketplace.
  • Thiết lập một MCP server cục bộ để cho phép các tác nhân AI tương tác với triển khai MongoDB tự quản lý.
  • Tích hợp các thao tác cơ sở dữ liệu trực tiếp vào quy trình làm việc lập trình của tác nhân để tạo ứng dụng dựa trên dữ liệu.

Đã chạy thử thật · 27 tool

Chúng tôi đã khởi động MCP server này trong máy ảo cách ly, và nó cung cấp các tool sau:

  • 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 · 8/10/2026

Kiểm tra an toàn

Cẩn thận

Dùng được, nhưng nên đọc ghi chú trước.

  • ●Đọc file chứa thông tin đăng nhập (SSH key, token cloud hoặc npm).skills/mongodb-mcp-v3-migration/SKILL.md

Quét tự động các file trong repo. Luôn xem lại code trước khi chạy.

Trích từ 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

Xem mã nguồn trên GitHub