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.
Tip
Using 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.
Note
The MCP Server configuration file examples include --readOnly
to ensure read-only access to data. Typically, enable read-only
mode to prevent data changes.
To enable write operations, omit --readOnly or set the
operating system environment variable MDB_MCP_READ_ONLY to
false. For more information, see
Enabling MCP Server Read-Only Mode.
The MCP Server configuration file examples set the type field to
"stdio".
type can be set to one of the following:
"stdio", which uses the standard input and output for communications with the MCP Server.stdiois suitable for most AI clients. Typically usestdio."http", which enables HTTP communications with the MCP Server. You can then use HTTP to interact with the MCP Server from a Web client.Warning
HTTP is NOT recommended for production use without implementing authentication and security.
The MCP Server configuration file examples also set the MCP Server name
to "MongoDB". You can change the server name to match the name of
your MCP Server after you start it. The server name identifies the MCP
Server to the AI client.