MongoDB CLI Configuration File

The MongoDB CLI configuration file stores your profiles. You can update the settings stored in your configuration file by editing the file with a text editor or by using the mongocli config set command.


Your API keys are like passwords. The configuration file stores API keys in plaintext, so ensure that you secure the configuration file appropriately.

Configuration File Location

The first time you run the mongocli config command, the MongoDB CLI creates a configuration file called mongocli.toml. The MongoDB CLI grants the user who ran the command read and write access to the file. The MongoDB CLI saves the configuration file to the folder where the system stores application configuration files, which is defined by the $XDG_CONFIG_HOME environment variable. By default, this location is the /.config folder of the user’s home directory. If this folder doesn’t exist, the MongoDB CLI creates the folder and grants the user read, write, and execute permissions.


The MongoDB CLI configuration file stores related settings and API keys in groups called profiles. You can create or define multiple profiles so that you can use the MongoDB CLI to access different MongoDB services or projects from the same terminal.

To run MongoDB CLI with a specific profile, append the --profile <profileName> option to the command. If you omit the --profile parameter, MongoDB CLI looks for a profile named default in the configuration file.


The following example configuration file contains two profiles, default and myOpsManager.

The default profile connects to a Atlas deployment and contains the following settings:

  • An organization ID
  • API keys
  • A project ID

The myOpsManager profile connects to an Ops Manager deployment and contains contains the following settings:

  • The Ops Manager base URL
  • An organization ID
  • API keys
  • A project ID
# ~/.config/mongocli.toml

  organization_id = "qwer5678uiop23jb45lk78mn"
  public_api_key = "ABCDEFG"
  project_id= "5e2f04ecf10fcd33c7d4077e"
  private_api_key = "e750d2bf-1234-4cde-5678-ca4dcbcac9a4"
  service = "cloud"

  ops_manager_url = "http://localhost:9080/"
  organization_id = "jklsa23123dsdf3jj456hs2"
  public_api_key = "HIJKLMN"
  project_id = "kk12jdn43jd123dkdkf97jg"
  private_api_key = "e750d2bf-9101-4cde-1121-ca4dcbcac9a5"
  service = "ops-manager"

To use MongoDB CLI with the default profile, omit the --profile option from the command:

mongocli <command>

To use MongoDB CLI with the myOpsManager profile, append the --profile myOpsManager option to the command:

mongocli <command> --profile myOpsManager