This page describes the MongoDB MCP Server JSON configuration file. The file controls how the MCP Server connects to your MongoDB database cluster, along with other MCP Server settings.
Typically, you use the MCP Server setup utility to create an initial configuration file. For details, see Configure MCP Server File.
MCP Server Configuration File Details
The following steps show how to configure a file. You select your MCP client and MongoDB deployment type from the drop-down menus in the following steps to see the corresponding configuration steps. If your preferred client isn't listed, use the steps as guidelines and refer to the documentation for your AI client.
You can add settings to an existing file, or manually create a file.
提示
使用VS Code?
If you're using VS Code, the MongoDB VS Code Extension includes the MongoDB MCP Server with automatic setup and connection management. To learn more, see MongoDB MCP Server in VS Code Extension.
注意
MCP 服务器配置文件示例包括 --readOnly,以确保对数据进行只读访问权限。通常,启用只读模式以防止数据更改。
要启用写入操作,请省略 --readOnly 或将操作系统环境变量 MDB_MCP_READ_ONLY设立为 false。有关更多信息,请参阅启用 MCP 服务器只读模式。
MCP 服务器配置文件示例将 type字段设立为 "stdio"。
type 可以设立为以下之一:
"stdio",它使用标准输入和输出与 MCP 服务器进行通信。stdio适用于大多数AI客户端。通常使用stdio。"http",这将启用与 MCP 服务器的HTTP通信。然后,您可以使用HTTP从 Web客户端与 MCP 服务器交互。警告
在未实现身份验证和安全性的情况下,不建议将HTTP用于生产用途。
MCP 服务器配置文件示例还将 MCP 服务器名称设立为 "MongoDB"。启动 MCP 服务器后,您可以更改服务器名称以匹配 MCP 服务器的名称。服务器名称向AI客户端标识 MCP 服务器。