# MD for: https://www.mercadopago.com.co/developers/pt/docs/mp-cli/install-mp-cli.md \# Install Mercado Pago CLI The Mercado Pago CLI is available for macOS, Linux, and Windows. In the tabs below, choose the installation method that best suits your operating system, then authenticate with your :toolTipComponent\[Access Token\]{content="Private key of the application created in Mercado Pago, used in the backend. You can access it from \*Your integrations\* > \*Application details\* > \*Tests\* > \*Test credentials\* or \*Production\* > \*Production credentials\*."} to start operating. ::::TabsComponent :::TabComponent{title="Homebrew — macOS / Linux"} The Mercado Pago CLI is distributed as a \_Homebrew\_ package compatible with macOS and Linux. To install it, run the following command in the terminal: \`\`\`bash brew install mercadopago/tap/mpcli \`\`\` If you have the previous version installed (\`mercadopago/tap/mp-cli\`), run \`brew uninstall mp-cli\` before installing. ::: :::TabComponent{title="Scoop — Windows"} The Mercado Pago CLI is available as a \_Scoop\_ package for Windows. To install it, run the following commands in the PowerShell terminal: If you have the previous version installed (\`mp-cli\`), run \`scoop uninstall mp-cli\` before installing. \`\`\`powershell scoop bucket add mercadopago https://github.com/mercadopago/homebrew-tap scoop install mpcli \`\`\` > WARNING > > On some Windows devices, antivirus software may remove the CLI executable immediately after installation. If this happens, add an exception for \`mpcli.exe\` in your antivirus settings and run the installation again. ::: :::TabComponent{title="npm — macOS / Linux / Windows"} The Mercado Pago CLI is available on \_npm\_ and can be installed on any operating system. To install it, run the following command in the terminal: If you have the previous version installed (\`mercadopago-cli\`), run \`npm uninstall -g mercadopago-cli\` before installing. \`\`\`bash npm install -g @mercadopago/mpcli \`\`\` > WARNING > > On some Windows devices, antivirus software may remove the CLI executable immediately after installation. If this happens, add an exception for \`mpcli.exe\` in your antivirus settings and run the installation again. ::: :::TabComponent{title="Script — macOS / Linux"} To install the Mercado Pago CLI via script on macOS or Linux, run the following command in the terminal: \`\`\`bash curl -fsSL https://raw.githubusercontent.com/mercadopago/homebrew-tap/main/install.sh | sh \`\`\` ::: :::: To confirm that the installation was completed successfully, run the following command: \`\`\`bash mpcli --version \`\`\` Before using any command, authenticate with your :toolTipComponent\[Access Token\]{content="Private key of the application created in Mercado Pago, used in the backend. You can access it from \*Your integrations\* > \*Application details\* > \*Tests\* > \*Test credentials\* or \*Production\* > \*Production credentials\*."} — access your credentials in \[Your integrations\](https://www.mercadopago.com.co/developers/panel/app) and run: \`\`\`bash mpcli login \`\`\` For advanced authentication options, see \[Authenticate credentials\](#authenticate-credentials) below. ### Shell completion To enable command autocompletion in the terminal: \`\`\`bash mpcli completion bash >> \~/.bashrc mpcli completion zsh >> \~/.zshrc mpcli completion fish >> \~/.config/fish/completions/mp.fish mpcli completion powershell \`\`\` ## Authenticate credentials The Mercado Pago CLI stores credentials in the operating system's native keychain, preventing tokens from being exposed in configuration files, shell history, or logs. > NOTE > > Our CLI uses Keychain on macOS, libsecret on Linux, and Credential Manager on Windows. ### Log in > WARNING > > If you are using a corporate macOS device, an additional step is required before logging in. \> In these cases, \`\~/.config\` is owned by root and \`mpcli login\` may fail with \`permission denied\`. To fix it, manually create the directory before logging in: \`sudo mkdir -p \~/.config/mp && sudo chown $USER \~/.config/mp\`. ::::TabsComponent :::TabComponent{title="Standard login"} To get your :toolTipComponent\[Access Token\]{content="Private key of the application created in Mercado Pago, used in the backend. You can access it from \*Your integrations\* > \*Application details\* > \*Tests\* > \*Test credentials\* or \*Production\* > \*Production credentials\*."}, go to \[Your integrations\](https://www.mercadopago.com.co/developers/panel/app), select or create an application, and copy the token from \*\*Production credentials\*\* or \*\*Test credentials\*\* in the left menu. Then run: \`\`\`bash mpcli login --token \`\`\` ::: :::TabComponent{title="Multiple profiles"} To work with more than one account or environment without having to re-authenticate on each switch, use the \`--profile\` flag to name and alternate between the accounts and environments you are working with. \`\`\`bash mpcli login --token APP\_USR-... --profile production mpcli login --token TEST-... --profile sandbox mpcli config use sandbox mpcli payments list --profile sandbox \`\`\` ::: :::TabComponent{title="CI/CD"} To use the Mercado Pago CLI in pipelines and automated environments, export the Access Token as an environment variable and use the \`--no-interactive\` flag to ensure the execution flow is not interrupted. In this case, the CLI ignores the keychain and operates in a non-blocking way: \`\`\`bash # Production environment export MP\_ACCESS\_TOKEN="APP\_USR-..." mpcli payments list --no-interactive # Test environment export MP\_ACCESS\_TOKEN="TEST-..." mpcli payments list --no-interactive \`\`\` The structured \`JSON\` output allows you to integrate the CLI with any script. See examples below: - Check payment status with error handling: \`\`\`bash RESULT=$(mpcli payments get 12345678 --no-interactive) STATUS=$(echo "$RESULT" | jq -r '.status') if \[ "$STATUS" = "error" \]; then echo "Error: $(echo "$RESULT" | jq -r '.error.message')" exit 1 fi echo "Status: $(echo "$RESULT" | jq -r '.data.status')" \`\`\` - Create a preference and capture the generated ID: \`\`\`bash RESULT=$(mpcli preferences create --data @pref.json --no-interactive) if \[ "$(echo "$RESULT" | jq -r '.status')" = "error" \]; then echo "Error: $(echo "$RESULT" | jq -r '.error.message')" exit 1 fi PREF\_ID=$(echo "$RESULT" | jq -r '.data.id') \`\`\` ::: :::: When interpreting the login response, note the following behavior: The \`environment\` field reflects the token type, not the actual account type — a test account token may show \`"environment": "production"\` and this is expected behavior. ### Log out Use the command below to end the CLI's access to the account and remove the credentials stored in the keychain. If you are working with multiple profiles, specify the name of the profile you want to disconnect: \`\`\`bash mpcli logout mpcli logout --profile sandbox \`\`\` ## Configure the project This configuration is ideal for teams looking to use the Mercado Pago CLI on a recurring basis. To get started, create the \`.mp.toml\` file at the root of your repository with your team's default settings, such as credentials profile and country of operation: \`\`\`toml \[defaults\] profile = "checkout-pro-sandbox" # default credentials profile site\_id = "MLB" # country of operation \[output\] no\_color = false # disable colored output \`\`\` ### Configuration sources The CLI determines which configuration source to use following the order from most specific to least specific: | Source | Recommended use | |---|---| | CLI flags (\`--profile\`, \`--json\`, etc.) | Override any configuration on a one-off basis without changing defaults. | | Environment variables (\`MP\_PROFILE\`, \`MP\_ACCESS\_TOKEN\`) | Authentication in CI/CD and automated environments. | | \`.mp.toml\` in the current directory | Shared team defaults in the repository. | | \`\~/.config/mp/config.toml\` | Personal developer preferences. | | Internal defaults | Applied when no other source is configured. |