Navigation

Environment Variables

For easier scripting, you can specify configuration settings by using environment variables.

Precedence

  • When you run a command, any settings that you specified with environment variables take precedence over the profile stored in the configuration file.
  • When you run a command using the --projectId option, the command line option takes precedence over both the environment variable and the profile stored in the configuration file.

Supported Environment Variables

The MongoDB CLI supports the following environment variables:

Variable Description
MCLI_PUBLIC_API_KEY Sets the public API key for commands that interact with your MongoDB service.
MCLI_PRIVATE_API_KEY Sets the private API key for commands that interact with your MongoDB service.
MCLI_ORG_ID Sets the organization ID for commands that require the --orgId option.
MCLI_PROJECT_ID Sets the project ID for commands that require the --projectId option.
MCLI_OPS_MANAGER_URL For Ops Manager only, sets the base URL for API calls.
MCLI_SERVICE

Sets the MongoDB service type. Valid values are:

Value Service
cloud
default
MongoDB Atlas
cloud-manager MongoDB Cloud Manager
ops-manager MongoDB Ops Manager