Docs Menu
Docs Home
/ /
MongoDB Command Line Interface
/

Environment Variables

On this page

  • Precedence
  • Supported Environment Variables

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

  • 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.

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. The URL must end with a forward slash (i.e. /).
MCLI_SERVICE

Sets the MongoDB service type. Valid values are:

Value
Service
cloud
default
cloud-manager
ops-manager
MCLI_OUTPUT

Sets the output fields and format. Valid values are:

Value
Output Format
Empty
default
Human-readable output that includes all fields that MongoDB CLI returns.
json
JSON output that includes all fields that MongoDB CLI returns.
json-path
JSON output that includes the fields that you specify.
go-template
Custom-formatted output that includes the fields that you specify in a Go template.
MCLI_MONGOSH_PATH
The full path on your local system to the MongoDB Shell, mongosh.
MCLI_OPS_MANAGER_CA_CERTIFICATE
Ops Manager only
If applicable, the full path on your local system to the PEM-encoded Certificate Authority (CA) certificate used to sign the client and Ops Manager TLS certificates.
MCLI_OPS_MANAGER_SKIP_VERIFY
Ops Manager only

When set to yes, the MCLI_OPS_MANAGER_CA_CERTIFICATE TLS certificate is not verified. This prevents your connections from being rejected due to an invalid certificate.

Important

Setting MCLI_OPS_MANAGER_SKIP_VERIFY to yes is insecure and is not recommended in production environments.

Back

MongoDB CLI Configuration File