如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
A Model Context Protocol server for interacting with MongoDB Databases and MongoDB Atlas.
shellnode -v
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:
You may provide either a MongoDB connection string OR Atlas API credentials:
Option A: No configuration
shelldocker run --rm -i \ mongodb/mongodb-mcp-server:latest
Option B: With MongoDB connection string
shelldocker run --rm -i \ -e MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" \ mongodb/mongodb-mcp-server:latest
Option C: With Atlas API credentials
shelldocker run --rm -i \ -e MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" \ -e MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" \ mongodb/mongodb-mcp-server:latest
MCP Configuration File
Without options:
json{ "mcpServers": { "MongoDB": { "command": "docker", "args": ["run", "--rm", "-i", "mongodb/mongodb-mcp-server:latest"] } } }
With connection string:
json{ "mcpServers": { "MongoDB": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "MDB_MCP_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/myDatabase", "mongodb/mongodb-mcp-server:latest" ] } } }
With Atlas API credentials:
json{ "mcpServers": { "MongoDB": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "MDB_MCP_API_CLIENT_ID=your-atlas-service-accounts-client-id", "-e", "MDB_MCP_API_CLIENT_SECRET=your-atlas-service-accounts-client-secret", "mongodb/mongodb-mcp-server:latest" ] } } }
MongoDB Atlas Tools
atlas-list-orgs - Lists MongoDB Atlas organizationsatlas-list-projects - Lists MongoDB Atlas projectsatlas-create-project - Creates a new MongoDB Atlas projectatlas-list-clusters - Lists MongoDB Atlas clustersatlas-inspect-cluster - Inspect a specific MongoDB Atlas clusteratlas-create-free-cluster - Create a free MongoDB Atlas clusteratlas-connect-cluster - Connects to MongoDB Atlas clusteratlas-inspect-access-list - Inspect IP/CIDR ranges with access to MongoDB Atlas clustersatlas-create-access-list - Configure IP/CIDR access list for MongoDB Atlas clustersatlas-list-db-users - List MongoDB Atlas database usersatlas-create-db-user - List MongoDB Atlas database usersNOTE: atlas tools are only available when you set credentials on configuration section.
MongoDB Database Tools
connect - Connect to a MongoDB instancefind - Run a find query against a MongoDB collectionaggregate - Run an aggregation against a MongoDB collectioncount - Get the number of documents in a MongoDB collectioninsert-one - Insert a single document into a MongoDB collectioninsert-many - Insert multiple documents into a MongoDB collectioncreate-index - Create an index for a MongoDB collectionupdate-one - Update a single document in a MongoDB collectionupdate-many - Update multiple documents in a MongoDB collectionrename-collection - Rename a MongoDB collectiondelete-one - Delete a single document from a MongoDB collectiondelete-many - Delete multiple documents from a MongoDB collectiondrop-collection - Remove a collection from a MongoDB databasedrop-database - Remove a MongoDB databaselist-databases - List all databases for a MongoDB connectionlist-collections - List all collections for a given databasecollection-indexes - Describe the indexes for a collectioncollection-schema - Describe the schema for a collectioncollection-storage-size - Get the size of a collection in MBdb-stats - Return statistics about a MongoDB databaseThe MongoDB MCP Server can be configured using multiple methods, with the following precedence (highest to lowest):
| Option | Description |
|---|---|
apiClientId | Atlas API client ID for authentication |
apiClientSecret | Atlas API client secret for authentication |
connectionString | MongoDB connection string for direct database connections (optional users may choose to inform it on every tool call) |
logPath | Folder to store logs |
disabledTools | An array of tool names, operation types, and/or categories of tools that will be disabled |
readOnly | When set to true, only allows read and metadata operation types, disabling create/update/delete operations |
telemetry | When set to disabled, disables telemetry collection |
Log Path
Default log location is as follows:
%LOCALAPPDATA%\mongodb\mongodb-mcp\.app-logs~/.mongodb/mongodb-mcp/.app-logsDisabled 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:
export MDB_MCP_DISABLED_TOOLS="create,update,delete,atlas,collectionSchema".--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, list collections, collection schema, etc.Read-Only Mode
The readOnly configuration option allows you to restrict the MCP server to only use tools with "read" 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:
export MDB_MCP_READ_ONLY=true--readOnlyWhen 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.
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:
export MDB_MCP_TELEMETRY=disabled--telemetry disabledexport DO_NOT_TRACK=1To use the Atlas API tools, you'll need to create a service account in MongoDB Atlas:
Create a Service Account:
To learn more about Service Accounts, check the MongoDB Atlas documentation.
Save Client Credentials:
Add Access List Entry:
Configure the MCP Server:
apiClientId and apiClientSecretEnvironment Variables
Set environment variables with the prefix MDB_MCP_ followed by the option name in uppercase with underscores:
shell# 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 a custom MongoDB connection string export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" export MDB_MCP_LOG_PATH="/path/to/logs"
MCP configuration file examples
Connection String with environment variables
json{ "mcpServers": { "MongoDB": { "command": "docker", "args": ["run", "-i", "--rm", "mongodb/mongodb-mcp-server"], "env": { "MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:password@cluster.mongodb.net/myDatabase" } } } }
Atlas API credentials with environment variables
json{ "mcpServers": { "MongoDB": { "command": "docker", "args": ["run", "-i", "--rm", "mongodb/mongodb-mcp-server"], "env": { "MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id", "MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret" } } } }
Command-Line Arguments
Pass configuration options as command-line arguments when starting the server:
shelldocker run -i --rm mongodb/mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" --apiClientSecret="your-atlas-service-accounts-client-secret" --connectionString="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" --logPath=/path/to/logs
MCP configuration file examples
Connection String with command-line arguments
json{ "mcpServers": { "MongoDB": { "command": "docker", "args": [ "run", "-i", "--rm", "mongodb/mongodb-mcp-server", "--connectionString", "mongodb+srv://username:password@cluster.mongodb.net/myDatabase" ] } } }
Atlas API credentials with command-line arguments
json{ "mcpServers": { "MongoDB": { "command": "docker", "args": [ "run", "-i", "--rm", "mongodb/mongodb-mcp-server", "--apiClientId", "your-atlas-service-accounts-client-id", "--apiClientSecret", "your-atlas-service-accounts-client-secret" ] } } }
Interested in contributing? Great! Please check our https://github.com/mongodb-js/mongodb-mcp-server/blob/main/CONTRIBUTING.md for guidelines on code contributions, standards, adding new tools, and troubleshooting information.
以下是 mongodb/mongodb-mcp-server 相关的常用 Docker 镜像,适用于 不同场景 等不同场景:
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务