🔌
MCP工具

mongodb-mcp-server

基于 TypeScript · 让 AI 助手直接操作你的系统与工具
⭐ 1.0k Stars 🍴 246 Forks 💻 TypeScript 📄 Apache-2.0 🏷 AI 8.8分
8.8AI 综合评分
mcpmcp-servermongodbmongodb-atlasmongodb-databasetypescript
✦ AI Skill Hub 推荐

AI Skill Hub 强烈推荐:mongodb-mcp-server 是一款优质的MCP工具。已获得 1.0k 颗 GitHub Star,AI 综合评分 8.8 分,在同类工具中表现稳健。如果你正在寻找可靠的MCP工具解决方案,这是一个值得深入了解的选择。

📚 深度解析
mongodb-mcp-server 是一款基于 MCP(Model Context Protocol)标准协议的 AI 工具扩展。MCP 协议由 Anthropic 开发并开源,旨在建立 AI 模型与外部工具之间的标准化通信接口,目前已被 Claude Desktop、Claude Code、Cursor 等主流 AI 工具采纳。

通过安装 mongodb-mcp-server,你的 AI 助手将获得额外的工具调用能力,可以用自然语言直接操控该工具的功能,无需学习复杂的命令行语法。MCP 工具的核心价值在于"一次配置,永久增强"——配置完成后,每次与 AI 对话时都可以无缝调用这些工具。

在技术实现上,MCP 工具通过标准的 JSON-RPC 协议与 AI 客户端通信,工具的功能以"工具列表"的形式暴露给 AI 模型,AI 可以按需调用。mongodb-mcp-server 提供了结构化的工具调用接口,使 AI 模型能够精确地理解和使用每个功能点,显著降低 AI 在工具使用上的错误率。

与传统的 API 集成相比,MCP 工具的优势在于无需编写代码——用户只需在配置文件中添加几行 JSON,即可让 AI 获得全新能力。AI Skill Hub 将 mongodb-mcp-server 评为 AI 评分 8.8 分,属于同类工具中的优质选择。
📋 工具概览

mongodb-mcp-server 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。

GitHub Stars
⭐ 1.0k
开发语言
TypeScript
支持平台
Windows / macOS / Linux
维护状态
正常维护,社区驱动
开源协议
Apache-2.0
AI 综合评分
8.8 分
工具类型
MCP工具
Forks
246
📖 中文文档
以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

mongodb-mcp-server 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。

📌 核心特色
  • 通过标准 MCP 协议与 Claude、Cursor 等主流 AI 客户端深度集成
  • 提供结构化工具调用接口,显著降低 AI 集成复杂度
  • 支持 Claude Desktop 和 Claude Code 无缝接入,开箱即用
  • 可与其他 MCP 工具组合叠加,构建完整 AI 工作站
  • 轻量无侵入设计,不影响现有系统架构
🎯 主要使用场景
  • 在 Claude Desktop 对话中直接调用本地工具,实现 AI 与系统的深度联动
  • 通过自然语言驱动复杂的多步骤自动化任务,代替繁琐手动操作
  • 将多个 MCP 工具组合使用,构建个人专属 AI 工作站
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/mongodb-js/mongodb-mcp-server

# 方式二:手动配置 claude_desktop_config.json
{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": ["-y", "mongodb-mcp-server"]
    }
  }
}

# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
📋 安装步骤说明
  1. 确认已安装 Node.js(v18 或以上版本)
  2. 打开 Claude Desktop 或 Claude Code 的 MCP 配置文件
  3. 按「交给 Agent 安装 → Claude Desktop」标签中的 JSON 配置填入 mcpServers 字段
  4. 保存配置文件并重启 Claude 客户端
  5. 重启后,在对话中即可使用本工具
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 安装后在 Claude 对话中直接使用
# 示例:
用户: 请帮我用 mongodb-mcp-server 执行以下任务...
Claude: [自动调用 mongodb-mcp-server MCP 工具处理请求]

# 查看可用工具列表
# 在 Claude 中输入:"列出所有可用的 MCP 工具"
以下配置示例基于典型使用场景生成,具体参数请参照官方文档调整。
配置示例
// claude_desktop_config.json 配置示例
{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": ["-y", "mongodb-mcp-server"],
      "env": {
        // "API_KEY": "your-api-key-here"
      }
    }
  }
}

// 保存后重启 Claude Desktop 生效
📑 README 深度解析 真实文档 完整度 62/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

简介

Install in VS Code Install in Cursor

Prerequisites

  • Node.js
  • At least 20.19.0
  • When using v22 then at least v22.12.0
  • Otherwise any version 23+
node -v
  • A MongoDB connection string or Atlas API credentials, the Server will not start unless configured.
  • 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.

Setup

Then start the docker container

docker run --rm -i \ -e MDB_MCP_CONNECTION_STRING \ -e MDB_MCP_READ_ONLY="true" \ mongodb/mongodb-mcp-server:latest


> **💡 Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions.

##### Option C: With Atlas API credentials
shell

Then start the docker container

docker run --rm -i \ -e MDB_MCP_API_CLIENT_ID \ -e MDB_MCP_API_CLIENT_SECRET \ -e MDB_MCP_READ_ONLY="true" \ mongodb/mongodb-mcp-server:latest


> **💡 Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions.

##### Docker in MCP Configuration File

Without options:
json { "mcpServers": { "MongoDB": { "command": "docker", "args": [ "run", "--rm", "-e", "MDB_MCP_READ_ONLY=true", "-i", "mongodb/mongodb-mcp-server:latest" ] } } }

With connection string:
json { "mcpServers": { "MongoDB": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "MDB_MCP_CONNECTION_STRING", "-e", "MDB_MCP_READ_ONLY=true", "mongodb/mongodb-mcp-server:latest" ], "env": { "MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:password@cluster.mongodb.net/myDatabase" } } } }

With Atlas API credentials:
json { "mcpServers": { "MongoDB": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "MDB_MCP_READ_ONLY=true", "-e", "MDB_MCP_API_CLIENT_ID", "-e", "MDB_MCP_API_CLIENT_SECRET", "mongodb/mongodb-mcp-server:latest" ], "env": { "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id", "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret" } } } }

#### Option 5: Running as an HTTP Server

> **⚠️ Security Notice:** This server now supports Streamable HTTP transport for remote connections. **HTTP transport is NOT recommended for production use without implementing proper authentication and security measures.**

**Suggested Security Measures Examples:**

- Implement authentication (e.g., API gateway, reverse proxy)
- Use HTTPS/TLS encryption
- Deploy behind a firewall or in private networks
- Implement rate limiting
- Never expose directly to the internet

For more details, see [MCP Security Best Practices](https://modelcontextprotocol.io/docs/concepts/transports#security-considerations).

You can run the MongoDB MCP Server as an HTTP server instead of the default stdio transport. This is useful if you want to interact with the server over HTTP, for example from a web client or to expose the server on a specific port.

To start the server with HTTP transport, use the `--transport http` option:
shell npx -y mongodb-mcp-server@latest --transport http

By default, the server will listen on `http://127.0.0.1:3000`. You can customize the host and port using the `--httpHost` and `--httpPort` options:
shell npx -y mongodb-mcp-server@latest --transport http --httpHost=0.0.0.0 --httpPort=8080

- `--httpHost` (default: 127.0.0.1): The host to bind the HTTP server.
- `--httpPort` (default: 3000): The port number for the HTTP server.

> **Note:** The default transport is `stdio`, which is suitable for integration with most MCP clients. Use `http` transport if you need to interact with the server over HTTP.

#### Option 6: Copilot CLI

You can use the Copilot CLI to interactively add the MCP server:
shell /mcp add

Alternatively, create or edit the configuration file `~/.copilot/mcp-config.json` and add:
json { "mcpServers": { "MongoDB": { "command": "npx", "args": ["-y", "mongodb-mcp-server@latest", "--readOnly"], "env": { "MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase" } } } }

For more information, see the [Copilot CLI documentation](https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli).

#### Option 7: OpenCode

Create or edit your OpenCode config file (`~/.config/opencode/opencode.json` or project-specific `./opencode.json`):
json { "$schema": "https://opencode.ai/config.json", "mcp": { "MongoDB": { "type": "local", "command": ["npx", "-y", "mongodb-mcp-server@latest", "--readOnly"], "enabled": true, "environment": { "MDB_MCP_CONNECTION_STRING": "mongodb://localhost:27017/myDatabase" } } } } ```

For more information about configuring OpenCode as an MCP client, including the expected syntax and options, see the OpenCode MCP servers documentation.

🚀Deploy on Public Clouds

You can deploy the MongoDB MCP Server to your preferred cloud provider using the deployment assets under deploy/. Each guide explains the prerequisites, configuration, and automation scripts that streamline the rollout.

Quick Start

🔒 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:

  • Windsurf: https://docs.windsurf.com/windsurf/mcp
  • VSCode: https://code.visualstudio.com/docs/copilot/chat/mcp-servers
  • Claude Desktop: https://modelcontextprotocol.io/quickstart/user
  • Cursor: https://docs.cursor.com/context/model-context-protocol
  • Copilot CLI: https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli
  • Opencode CLI: https://opencode.ai/docs/mcp-servers
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: 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 3: 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.

```shell

Set your credentials as environment variables first

export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret"

Set your credentials as environment variables first

export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase"

Set your credentials as environment variables first

export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret"

Configuration

🔒 Security Best Practice: We strongly recommend using environment variables for sensitive configuration such as API credentials (MDB_MCP_API_CLIENT_ID, MDB_MCP_API_CLIENT_SECRET) and connection strings (MDB_MCP_CONNECTION_STRING) instead of command-line arguments. Environment variables are not visible in process lists and provide better security for your sensitive data.

The MongoDB MCP Server can be configured using multiple methods, with the following precedence (highest to lowest):

  1. Command-line arguments
  2. Environment variables
  3. Configuration File

Configuration Options

Environment Variable / CLI OptionDefaultDescription
MDB_MCP_ALLOW_REQUEST_OVERRIDES / --allowRequestOverridesfalseWhen set to true, allows configuration values to be overridden via request headers and query parameters.
MDB_MCP_API_CLIENT_ID / --apiClientId<not set>Atlas API client ID for authentication. Required for running Atlas tools.
MDB_MCP_API_CLIENT_SECRET / --apiClientSecret<not set>Atlas API client secret for authentication. Required for running Atlas tools.
MDB_MCP_ASSISTANT_BASE_URL / --assistantBaseUrl"https://knowledge.mongodb.com/api/v1/"Base URL for the MongoDB Assistant API.
MDB_MCP_ATLAS_TEMPORARY_DATABASE_USER_LIFETIME_MS / --atlasTemporaryDatabaseUserLifetimeMs14400000Time in milliseconds that temporary database users created when connecting to MongoDB Atlas clusters will remain active before being automatically deleted.
MDB_MCP_CONFIRMATION_REQUIRED_TOOLS / --confirmationRequiredTools"atlas-create-access-list,atlas-create-db-user,drop-database,drop-collection,delete-many,drop-index,atlas-streams-manage,atlas-streams-teardown"Comma separated values of tool names that require user confirmation before execution. Requires the client to support elicitation.
MDB_MCP_CONNECTION_STRING / --connectionString<not set>MongoDB connection string for direct database connections. Optional, if not set, you'll need to call the connect tool before interacting with MongoDB data.
MDB_MCP_DISABLED_TOOLS / --disabledTools""Comma separated values of tool names, operation types, and/or categories of tools that will be disabled.
MDB_MCP_DRY_RUN / --dryRunfalseWhen true, runs the server in dry mode: dumps configuration and enabled tools, then exits without starting the server.
MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS / --exportCleanupIntervalMs120000Time in milliseconds between export cleanup cycles that remove expired export files.
MDB_MCP_EXPORT_TIMEOUT_MS / --exportTimeoutMs300000Time in milliseconds after which an export is considered expired and eligible for cleanup.
MDB_MCP_EXPORTS_PATH / --exportsPathsee below\*Folder to store exported data files.
MDB_MCP_EXTERNALLY_MANAGED_SESSIONS / --externallyManagedSessionsfalseWhen true, the HTTP transport allows requests with a session ID supplied externally through the 'mcp-session-id' header. When an external ID is supplied, the initialization request is optional.
MDB_MCP_HEALTH_CHECK_HOST / --healthCheckHost<not set>Deprecated. Use monitoringServerHost instead. Host address to bind the healthCheck HTTP server to (only used when transport is 'http'). If provided, healthCheckPort must also be set.
MDB_MCP_HEALTH_CHECK_PORT / --healthCheckPort<not set>Deprecated. Use monitoringServerPort instead. Port number for the healthCheck HTTP server (only used when transport is 'http'). If provided, healthCheckHost must also be set.
MDB_MCP_HTTP_BODY_LIMIT / --httpBodyLimit102400Maximum size of the HTTP request body in bytes (only used when transport is 'http'). This value is passed as the optional limit parameter to the Express.js json() middleware.
MDB_MCP_HTTP_HEADERS / --httpHeaders"{}"Header that the HTTP server will validate when making requests (only used when transport is 'http').
MDB_MCP_HTTP_HOST / --httpHost"127.0.0.1"Host address to bind the HTTP server to (only used when transport is 'http').
MDB_MCP_HTTP_PORT / --httpPort3000Port number for the HTTP server (only used when transport is 'http'). Use 0 for a random port.
MDB_MCP_HTTP_RESPONSE_TYPE / --httpResponseType"sse"The HTTP response type for tool responses: 'sse' for Server-Sent Events, 'json' for standard JSON responses.
MDB_MCP_IDLE_TIMEOUT_MS / --idleTimeoutMs600000Idle timeout for a client to disconnect (only applies to http transport).
MDB_MCP_INDEX_CHECK / --indexCheckfalseWhen set to true, enforces that query operations must use an index, rejecting queries that perform a collection scan.
MDB_MCP_LOG_PATH / --logPathsee below\*Folder to store logs.
MDB_MCP_LOGGERS / --loggers"disk,mcp" see below\*Comma separated values of logger types.
MDB_MCP_MAX_BYTES_PER_QUERY / --maxBytesPerQuery16777216The maximum size in bytes for results from a find or aggregate tool call. This serves as an upper bound for the responseBytesLimit parameter in those tools.
MDB_MCP_MAX_DOCUMENTS_PER_QUERY / --maxDocumentsPerQuery100The maximum number of documents that can be returned by a find or aggregate tool call. For the find tool, the effective limit will be the smaller of this value and the tool's limit parameter.
MDB_MCP_MAX_TIME_M_S / --maxTimeMS<not set>The maximum time in milliseconds that operations are allowed to run on the MongoDB server. When set, this value is passed as the maxTimeMS option to read operations such as find, aggregate, and count.
MDB_MCP_MCP_CLIENT_LOG_LEVEL / --mcpClientLogLevel"debug"Minimum severity level for log messages forwarded to the MCP client.
MDB_MCP_MONITORING_SERVER_FEATURES / --monitoringServerFeatures"health-check"Features to expose on the monitoring server (only used when transport is 'http' and monitoringServerHost/monitoringServerPort are set).
MDB_MCP_MONITORING_SERVER_HOST / --monitoringServerHost<not set>Host address to bind the monitoring HTTP server to (only used when transport is 'http'). If provided, monitoringServerPort must also be set.
MDB_MCP_MONITORING_SERVER_PORT / --monitoringServerPort<not set>Port number for the monitoring HTTP server (only used when transport is 'http'). If provided, monitoringServerHost must also be set.
MDB_MCP_NOTIFICATION_TIMEOUT_MS / --notificationTimeoutMs540000Notification timeout for a client to be aware of disconnect (only applies to http transport).
MDB_MCP_PREVIEW_FEATURES / --previewFeatures""Comma separated values of preview features that are enabled.
MDB_MCP_READ_ONLY / --readOnlyfalseWhen set to true, only allows read, connect, and metadata operation types, disabling create/update/delete operations.
MDB_MCP_TELEMETRY / --telemetry"enabled"When set to disabled, disables telemetry collection.
MDB_MCP_TRANSPORT / --transport"stdio"Either 'stdio' or 'http'.
MDB_MCP_VOYAGE_API_KEY / --voyageApiKey""API key for Voyage AI embeddings service (required for creating Atlas Local deployments with auto-embed vector search capabilities).

Logger Options

The loggers configuration option controls where logs are sent. You can specify one or more logger types as a comma-separated list. The available options are:

  • mcp: Sends logs to the MCP client (if supported by the client/transport).
  • disk: Writes logs to disk files. Log files are stored in the log path (see logPath above).
  • stderr: Outputs logs to standard error (stderr), useful for debugging or when running in containers.

Default: disk,mcp (logs are written to disk and sent to the MCP client).

You can combine multiple loggers, e.g. --loggers disk stderr or export MDB_MCP_LOGGERS="mcp,stderr".

Example: Set logger via environment variable
export MDB_MCP_LOGGERS="disk,stderr"
💡 Platform Note: For Windows users, see Environment Variables for platform-specific instructions.
Example: Set logger via command-line argument
npx -y mongodb-mcp-server@latest --loggers mcp stderr
Log File Location

When using the disk logger, log files are stored in:

  • Windows: %LOCALAPPDATA%\mongodb\mongodb-mcp\.app-logs
  • macOS/Linux: ~/.mongodb/mongodb-mcp/.app-logs

You can override the log directory with the logPath option.

🔒 Security Guideline: The user account running the MCP server must have both read and write permissions to the logPath directory. Ensure this directory is properly secured with appropriate file system permissions to prevent unauthorized access to log files.

Disabled Tools

You can disable specific tools or categories of tools by using the disabledTools option. This option accepts an array of strings, where each string can be a tool name, operation type, or category.

The way the array is constructed depends on the type of configuration method you use:

  • For environment variable configuration, use a comma-separated string: export MDB_MCP_DISABLED_TOOLS="create,update,delete,atlas,collectionSchema".
  • For command-line argument configuration, use a space-separated string: --disabledTools create update delete atlas collectionSchema.

Categories of tools:

  • atlas - MongoDB Atlas tools, such as list clusters, create cluster, etc.
  • mongodb - MongoDB database tools, such as find, aggregate, etc.

Operation types:

  • create - Tools that create resources, such as create cluster, insert document, etc.
  • update - Tools that update resources, such as update document, rename collection, etc.
  • delete - Tools that delete resources, such as delete document, drop collection, etc.
  • read - Tools that read resources, such as find, aggregate, list clusters, etc.
  • metadata - Tools that read metadata, such as list databases/collections/indexes, infer collection schema, etc.
  • connect - Tools that allow you to connect or switch the connection to a MongoDB instance. If this is disabled, you will need to provide a connection string through the config when starting the server.

Require Confirmation

If your client supports elicitation, you can set the MongoDB MCP server to request user confirmation before executing certain tools.

When a tool is marked as requiring confirmation, the server will send an elicitation request to the client. The client with elicitation support will then prompt the user for confirmation and send the response back to the server. If the client does not support elicitation, the tool will execute without confirmation.

You can set the confirmationRequiredTools configuration option to specify the names of tools which require confirmation. By default, the following tools have this setting enabled: drop-database, drop-collection, delete-many, atlas-create-db-user, atlas-create-access-list.

Read-Only Mode

The readOnly configuration option allows you to restrict the MCP server to only use tools with "read", "connect", and "metadata" operation types. When enabled, all tools that have "create", "update" or "delete" operation types will not be registered with the server.

This is useful for scenarios where you want to provide access to MongoDB data for analysis without allowing any modifications to the data or infrastructure.

You can enable read-only mode using:

  • Environment variable: export MDB_MCP_READ_ONLY=true
  • Command-line argument: --readOnly
💡 Platform Note: For Windows users, see Environment Variables for platform-specific instructions.

When read-only mode is active, you'll see a message in the server logs indicating which tools were prevented from registering due to this restriction.

Index Check Mode

The indexCheck configuration option allows you to enforce that query operations must use an index. When enabled, queries that perform a collection scan will be rejected to ensure better performance.

This is useful for scenarios where you want to ensure that database queries are optimized.

You can enable index check mode using:

  • Environment variable: export MDB_MCP_INDEX_CHECK=true
  • Command-line argument: --indexCheck
💡 Platform Note: For Windows users, see Environment Variables for platform-specific instructions.

When index check mode is active, you'll see an error message if a query is rejected due to not using an index.

Exports

The data exported by the export tool is temporarily stored in the configured exportsPath on the machine running the MCP server until cleaned up by the export cleanup process. If the exportsPath configuration is not provided, the following defaults are used:

  • Windows: %LOCALAPPDATA%\mongodb\mongodb-mcp\exports
  • macOS/Linux: ~/.mongodb/mongodb-mcp/exports

The exportTimeoutMs configuration controls the time after which the exported data is considered expired and eligible for cleanup. By default, exports expire after 5 minutes (300000ms).

The exportCleanupIntervalMs configuration controls how frequently the cleanup process runs to remove expired export files. By default, cleanup runs every 2 minutes (120000ms).

🔒 Security Guideline: The user account running the MCP server must have both read and write permissions to the exportsPath directory. Ensure this directory is properly secured with appropriate file system permissions to prevent unauthorized access to exported data files, which may contain sensitive MongoDB data. Consider the sensitivity of your data when choosing the export location and apply restrictive permissions accordingly.

Telemetry

The telemetry configuration option allows you to disable telemetry collection. When enabled, the MCP server will collect usage data and send it to MongoDB.

You can disable telemetry using:

  • Environment variable: export MDB_MCP_TELEMETRY=disabled
  • Command-line argument: --telemetry disabled
  • DO_NOT_TRACK environment variable: export DO_NOT_TRACK=1
💡 Platform Note: For Windows users, see Environment Variables for platform-specific instructions.

Opting into Preview Features

The MongoDB MCP Server may offer functionality that is still in development and may change in future releases. These features are considered "preview features" and are not enabled by default. Generally, these features are well tested, but may not offer the complete functionality we intend to provide in the final release or we'd like to gather feedback before making them generally available. To enable one or more preview features, use the previewFeatures configuration option.

  • For environment variable configuration, use a comma-separated string: export MDB_MCP_PREVIEW_FEATURES="feature1,feature2".
  • For command-line argument configuration, use a space-separated string: --previewFeatures feature1 feature2.

List of available preview features:

  • mcpUI - Enables an optional web-based UI for interacting with the MCP server.

Configuration Methods

Configuration File

Store configuration in a JSON file and load it using the MDB_MCP_CONFIG environment variable.

🔒 Security Best Practice: Prefer using the MDB_MCP_CONFIG environment variable for sensitive fields over the configuration file or --config CLI argument. Command-line arguments are visible in process listings.
🔒 File Security: Ensure your configuration file has proper ownership and permissions, limited to the user running the MongoDB MCP server: Linux/macOS:
> chmod 600 /path/to/config.json
> chown your-username /path/to/config.json
> 
Windows: Right-click the file → Properties → Security → Restrict access to your user account only.

Create a JSON file with your configuration (all keys use camelCase):

{
  "connectionString": "mongodb://localhost:27017",
  "readOnly": true,
  "loggers": ["stderr", "mcp"],
  "apiClientId": "your-atlas-service-accounts-client-id",
  "apiClientSecret": "your-atlas-service-accounts-client-secret",
  "maxDocumentsPerQuery": 100
}

Linux/macOS (bash/zsh):

export MDB_MCP_CONFIG="/path/to/config.json"
npx -y mongodb-mcp-server@latest

Windows Command Prompt (cmd):

set "MDB_MCP_CONFIG=C:\path\to\config.json"
npx -y mongodb-mcp-server@latest

Windows PowerShell:

$env:MDB_MCP_CONFIG="C:\path\to\config.json"
npx -y mongodb-mcp-server@latest

Environment Variables

Set environment variables with the prefix MDB_MCP_ followed by the option name in uppercase with underscores:

Linux/macOS (bash/zsh):

```bash

Set sensitive data as environment variable

export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase"

Atlas API Access

To use the Atlas API tools, you'll need to create a service account in MongoDB Atlas:

ℹ️ Note: For a detailed breakdown of the minimum required permissions for each Atlas operation, see the Atlas API Permissions section below.

1. Create a Service Account: - Log in to MongoDB Atlas at cloud.mongodb.com - Navigate to Access Manager > Organization Access - Click Add New > Applications > Service Accounts - Enter name, description and expiration for your service account (e.g., "MCP, MCP Server Access, 7 days") - Assign only the minimum permissions needed for your use case. - See Atlas API Permissions for details. - Click "Create"

To learn more about Service Accounts, check the MongoDB Atlas documentation.

2. Save Client Credentials: - After creation, you'll be shown the Client ID and Client Secret - Important: Copy and save the Client Secret immediately as it won't be displayed again

3. Add Access List Entry: - Add your IP address to the API access list

4. Configure the MCP Server: - Use one of the configuration methods below to set your apiClientId and apiClientSecret

Atlas API Permissions

Security Warning: Granting the Organization Owner role is rarely necessary and can be a security risk. Assign only the minimum permissions needed for your use case.

Quick Reference: Required roles per operation

What you want to doSafest Role to Assign (where)
List orgs/projectsOrg Member or Org Read Only (Org)
Create new projectsOrg Project Creator (Org)
View clusters/databases in a projectProject Read Only (Project)
Create/manage clusters in a projectProject Cluster Manager (Project)
Manage project access listsProject IP Access List Admin (Project)
Manage database usersProject Database Access Admin (Project)
Manage stream processing resourcesProject Stream Processing Owner (Project)
  • Prefer project-level roles for most operations. Assign only to the specific projects you need to manage or view.
  • Avoid Organization Owner unless you require full administrative control over all projects and settings in the organization.

For a full list of roles and their privileges, see the Atlas User Roles documentation.

Set Atlas API credentials (via Service Accounts)

export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret"

Set Atlas API credentials (via Service Accounts)

$env:MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" $env:MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret"

⚡ 核心功能
👥 适合人群
Claude Desktop / Claude Code 用户AI 工具开发者需要扩展 AI 能力的专业人士自动化工程师
🎯 使用场景
  • 在 Claude Desktop 对话中直接调用本地工具,实现 AI 与系统的深度联动
  • 通过自然语言驱动复杂的多步骤自动化任务,代替繁琐手动操作
  • 将多个 MCP 工具组合使用,构建个人专属 AI 工作站
⚖️ 优点与不足
✅ 优点
  • +Apache-2.0 协议,可免费商用
  • +标准化 MCP 协议,生态互联性强
  • +与 Claude 官方生态无缝对接
  • +即插即用,配置简单快捷
⚠️ 不足
  • 依赖 Claude 客户端,非 Claude 用户无法使用
  • MCP 协议仍在持续演进,接口可能变更
  • 需要一定的配置步骤
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。

🔗 相关工具推荐
❓ 常见问题 FAQ
MCP(Model Context Protocol)是 Anthropic 推出的开放协议,专门用于 AI 助手(如 Claude)调用外部工具。与普通 API 不同,MCP 提供标准化的工具描述格式,AI 可以自动理解工具功能并决定何时调用,无需人工编写大量适配代码。
💡 AI Skill Hub 点评

总体来看,mongodb-mcp-server 是一款质量优秀的MCP工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。

⬇️ 获取与下载
⬇ 下载源码 ZIP

✅ Apache-2.0 协议 · 可免费商用 · 直接从 aiskill88 服务器下载,无需跳转 GitHub

📚 深入学习 mongodb-mcp-server
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 mongodb-mcp-server
原始描述 开源MCP工具:A Model Context Protocol server to connect to MongoDB databases and MongoDB Atla。⭐1.0k · TypeScript
Topics mcpmcp-servermongodbmongodb-atlasmongodb-databasetypescript
GitHub https://github.com/mongodb-js/mongodb-mcp-server
License Apache-2.0
语言 TypeScript
🔗 原始来源
🐙 GitHub 仓库  https://github.com/mongodb-js/mongodb-mcp-server

收录时间:2026-05-22 · 更新时间:2026-05-22 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。