MongoDB.local SF, Jan 15: See the speaker lineup & ship your AI vision faster. Use WEB50 to save 50%
Find out more >
Docs Menu
Docs Home
/ /

MongoDB MCP Server Configuration Options

The MCP Server has various options that you can set to connect to a MongoDB cluster and control MCP Server operations. You can set the options in a JSON configuration file, through a command line, or using operating system environment variables.

Use the following configuration options to configure the MCP Server.

Important

If you're a MongoDB Enterprise or MongoDB Atlas user and you require a specific authentication mechanism, see the MongoDB MCP Server Security section to learn about the configuration options for your authentication method.

CLI Option Name
OS Environment Variable Name
Type
Default
Description

apiClientId

MDB_MCP_API_CLIENT_ID

string

Not set

Atlas API client ID for authentication.

apiClientSecret

MDB_MCP_API_CLIENT_SECRET

string

Not set

Atlas API client secret for authentication.

connectionString

MDB_MCP_CONNECTION_STRING

string

Not set

Connection string for a direct database connection.

Sets the connection string at runtime to allow the client to directly connect to a cluster.

Important

The --connectionString CLI argument is deprecated. Use the MDB_MCP_CONNECTION_STRING environment variable instead. If environment variables are not an option, use the first positional argument.

Note

Typically, avoid providing the connection string at runtime because you expose the connection credentials to the large language model.

The connection string is used if the client has never connected before, or the client switches the connection to a new cluster if the client was previously connected.

After the client calls the connect or switch connection tool, the client reuses the same connection for subsequent operations. Therefore, you only need to call the connect or switch connection tool once or if you need to switch to a different connection.

dryRun

MDB_MCP_DRY_RUN

boolean

false

Use the dry-run option to examine your MCP Server configuration. When you enable the dry-run option, the MCP Server returns the MCP Server configuration settings and the list of enabled MongoDB MCP Server Tools.

To enable the dry-run option, set --dryRun in the configuration file or command line, or set the MDB_MCP_DRY_RUN operating system environment variable to true.

For more information, see Enabling MCP Server Dry-Run Mode.

loggers

MDB_MCP_LOGGERS

string

disk mcp

Specifies where the MCP Server sends the logs.

Set loggers to one or more of the following options:

  • disk, which writes logs to disk files located in the path specified in the logPath option.

  • mcp, which sends the logs to the AI client, if the client supports logging and transport protocol.

  • stderr, which sends the logs to the standard error output. This setting is useful for debugging or when running MCP in a container.

For example, to set loggers to mcp and stderr in the AI client JSON configuration file or the operating system command line, use --loggers mcp stderr.

To set the MDB_MCP_LOGGERS operating system environment variable to disk and stderr, use export MDB_MCP_LOGGERS="disk,stderr".

For more information about the logging options, see Troubleshoot MongoDB MCP Server.

logPath

MDB_MCP_LOG_PATH

string

Depends on the operating system

Directory that stores the MCP Server logs.

For more information about the log path and operating system specifics, see Troubleshoot MongoDB MCP Server.

disabledTools

MDB_MCP_DISABLED_TOOLS

array

Not set

An array of MCP tool names, operation types, or tool categories to disable.

For more information, see Disabling MCP Server Tools.

readOnly

MDB_MCP_READ_ONLY

boolean

false

To disable cluster write operations, set --readOnly in the configuration file or command line, or set the MDB_MCP_READ_ONLY operating system environment variable to true.

Default is to allow cluster write operations. Typically, always enable read-only mode.

For more information, see Enabling MCP Server Read-Only Mode.

indexCheck

MDB_MCP_INDEX_CHECK

boolean

false

If true, enforces that query operations must use an index and rejects queries that perform collection scans.

For more information, see Enabling Index Check.

telemetry

MDB_MCP_TELEMETRY

string

enabled

If disabled, MCP Server usage data collection is stopped.

For more information, see Disabling MCP Server Telemetry.

transport

MDB_MCP_TRANSPORT

string

stdio

Transport protocol for communications with the MCP Server.

Set transport to one of the following options:

  • stdio, which is the default. Uses the standard input and output for communications with the MCP Server. stdio is suitable for most AI clients.

  • http, which enables HTTP communications with the MCP Server. You can then use HTTP to interact with the MCP Server from a Web client or communicate with the MCP Server on a specific HTTP IP port.

    Warning

    HTTP transport is NOT recommended for production use without implementing proper authentication and security measures.

httpPort

MDB_MCP_HTTP_PORT

integer

3000

IP port number for HTTP communications with the MCP Server.

httpHost

MDB_MCP_HTTP_HOST

string

127.0.0.1

IP address for HTTP communications with the MCP Server.

With Streamable HTTP, the MCP Server is bound to localhost (127.0.0.1) by default. This ensures the MCP Server only accepts connections that originate on the same computer.

Warning

Binding to 0.0.0.0 exposes the MCP Server to the entire local network, which allows other devices on the same network to potentially access the MCP Server. This is a security risk and could allow unauthorized access to your database context. If you must expose the MCP Server outside of localhost, implement strong security authentication.

To learn more, see Remote Connections.

idleTimeoutMs

MDB_MCP_IDLE_TIMEOUT_MS

integer

600000

Idle timeout for a client to disconnect. Only applies to HTTP transport.

notificationTimeoutMs

MDB_MCP_NOTIFICATION_TIMEOUT_MS

integer

540000

Notification timeout for a client to be aware of disconnect. Only applies to HTTP transport.

authenticationMechanism

MDB_MCP_AUTHENTICATION_MECHANISM

string

SCRAM-SHA-256

SCRAM is the default authentication mechanism for MongoDB. To connect to your MongoDB deployments with the MongoDB MCP server using other authentication methods, see the following pages:

exportsPath

MDB_MCP_EXPORTS_PATH

string

Depends on the operating system

Directory that stores exported data files.

For more information about the export path and operating system specifics, see Export Data from MongoDB MCP Server.

exportTimeoutMs

MDB_MCP_EXPORT_TIMEOUT_MS

integer

300000

Time in milliseconds after which exported data files are eligible for deletion by the MCP Server cleanup process.

exportCleanupIntervalMs

MDB_MCP_EXPORT_CLEANUP_INTERVAL_MS

integer

120000

Time period in milliseconds between automatic executions of the MCP Server cleanup process that deletes expired export data files. The cleanup process is run automatically.

previewFeatures

MDB_MCP_PREVIEW_FEATURES

string

Not set

Comma separated values of preview features that are enabled. Valid values: search.

Vector search support in MCP is available as a preview feature. To enable this feature, set the previewFeatures flag or MDB_MCP_PREVIEW_FEATURES environment variable to search in your MCP configuration. To learn more, see MongoDB MCP Server Configuration Options.

The following options configure the MCP server's behavior when you use it to work with MongoDB Vector Search.

CLI Option Name
OS Environment Variable Name
Type
Default
Description

voyageApiKey

MDB_MCP_VOYAGE_API_KEY

string

Not set

Voyage AI API key for automatic embedding generation.

When you configure this option, the MCP Server automatically generates embeddings for:

  • Documents that you insert with the insert-many tool

  • The queryVector parameter in $vectorSearch aggregation queries

The MCP Server also validates that fields with vector search indexes contain valid embedding vectors to prevent breaking vector search indexes.

The MongoDB MCP server supports the following Voyage AI models:

  • voyage-3-large

  • voyage-3.5

  • voyage-3.5-lite

  • voyage-code-3

To learn more about Voyage AI, see the Voyage AI documentation.

For additional vector search configuration options, see Vector Search Options.

disableEmbeddingsValidation

MDB_MCP_DISABLE_EMBEDDINGS_VALIDATION

boolean

false

When set to true, disables validation of embedding dimensions.

By default, the MCP Server validates that fields with vector search indexes contain valid embedding vectors with the correct dimensions to prevent breaking vector search indexes. Enable this option to allow inserting raw values into embeddings fields without validation.

Warning

Disabling embeddings validation may result in documents with invalid embeddings that cannot be used with vector search indexes.

vectorSearchDimensions

MDB_MCP_VECTOR_SEARCH_DIMENSIONS

integer

1024

Default number of dimensions for vector search embeddings.

This value is used when creating vector search indexes and validating embeddings.

vectorSearchSimilarityFunction

MDB_MCP_VECTOR_SEARCH_SIMILARITY_FUNCTION

string

euclidean

Default similarity function for vector search. Set to one of the following values:

  • euclidean: Euclidean distance

  • cosine: Cosine similarity

  • dotProduct: Dot product similarity

The MCP server uses this value is as the default when creating vector search indexes unless specified otherwise. To learn more, see How to Index Fields for Vector Search.

The MCP Server accepts a positional argument that can be provided without specifying a CLI flag. The first positional argument is interpreted as the connection string for your MongoDB deployment.

As a security best practice, use the MDB_MCP_CONNECTION_STRING environment variable to set the connection string. If environment variables are not an option, use the first positional argument. For example:

"args": [
"-y",
"mongodb-mcp-server",
"mongodb+srv://<user-name>:<password>@<cluster-name>.mongodb.net/",
"--readOnly"
]

Back

Configure

On this page