Connect Codex CLI

Connect Harmonize MCP to Codex CLI, OpenAI's assistant that runs in your terminal.

Before you start: every user must first join their Harmonize organization. See MCP Setup Guide. You also need a ChatGPT account with Codex access, or OpenAI API credentials, and a terminal on macOS, Linux or WSL, or PowerShell on Windows. Commands are labeled by platform where they differ. Unlabeled commands work on every platform.

Install Codex and sign in

Every user, once per machine

  1. Run the installer for your platform on the machine where Codex will run. If you work on a remote VM, run it in the VM terminal, not on your laptop.

    macOS, Linux or WSL

    Bash
    curl -fsSL https://chatgpt.com/codex/install.sh | sh
    

    Windows PowerShell

    PowerShell
    powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
    
  2. Open a new terminal and confirm the install. The installer adds Codex to your PATH, and a new terminal window picks up the change.

    Bash
    codex --version
    
  3. If you see command not found or 'codex' is not recognized, add the install folder to your PATH with the command for your platform, then run codex --version again.

    macOS

    Bash
    echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
    

    Linux or WSL

    Bash
    echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
    

    Windows PowerShell (then open a new PowerShell window)

    PowerShell
    $codexBin = "$env:LOCALAPPDATA\Programs\OpenAI\Codex\bin"
    $currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
    [Environment]::SetEnvironmentVariable('PATH', "$currentPath;$codexBin", 'User')
    

    On a Mac set to the older Bash shell, use ~/.bash_profile in place of ~/.zshrc.

  4. Sign in to OpenAI. On a machine with a browser, run codex login. On a remote VM, use device login, open the link it prints on your laptop, and enter the code. Device login may need to be enabled in your ChatGPT workspace security settings.

    Bash
    codex login --device-auth
    
  5. Confirm with codex login status. This confirms your OpenAI sign-in only; Harmonize sign-in is below.

Add Harmonize MCP and sign in

Every user, once per machine

  1. Open your Codex configuration file (create it if needed) and add this entry. If a harmonize entry already exists, edit it instead of adding a second one. Replace <client-id> with the OAuth client ID: please refer to the Connection Guide in your onboarding email.

    • macOS, Linux or WSL: ~/.codex/config.toml

    • Windows: %USERPROFILE%\.codex\config.toml

    [mcp_servers.harmonize]
    url = "https://mcp.optimizedpayments.com/mcp"
    
    [mcp_servers.harmonize.oauth]
    client_id = "<client-id>"
    callback_port = 8787
    callback_url = "http://localhost:8787/callback"
    

    Confirm Codex can read it: codex mcp get harmonize

  2. Sign in to Harmonize. A login URL opens in your browser. Enter your Organization ID, followed by your email address and password for Harmonize. If your company uses single sign-on, you'll be sent to your company's sign-in page instead of entering a Harmonize password. You may occasionally need to sign in again.

    Bash
    codex mcp login harmonize
    
  3. On a remote VM, or if the browser shows ‘can’t reach this page’: run the login with --no-browser instead. It prints the login URL. Open it in the browser on your own computer and sign in. The browser is then sent to http://localhost:8787/callback, which can't be reached from your laptop. Copy the full URL from the address bar and paste it into the terminal prompt.

    Bash
    codex mcp login harmonize --no-browser
    
  4. Confirm it's connected with codex mcp list, then start codex and type /mcp. The Harmonize tools should appear. If you changed the configuration during a session, start a fresh one. If sign-in said it was successful but codex mcp list still shows Not logged in, run codex mcp login harmonize again.

Important: keep the client_id and the two callback lines exactly as shown. Sign-in needs them. If port 8787 is already in use, close the app using it and try again.

Start asking

Every user

  1. Start a session in the folder you want to work in: cd ~/your-project, then codex.

  2. Type /mcp. The Harmonize tools should be listed.

  3. Ask a question. Naming "harmonize" in your question tells Codex to use it rather than other sources.

  4. If Codex asks for approval, check the server and tool named, then allow it. Approval behaviour depends on your Codex settings and workspace policy.

Test it: ask "Use harmonize. How did Visa authorization approval rates trend last quarter?" More examples in MCP Example Questions and Troubleshooting.

If something goes wrong

  • TOML parse error or duplicate table: edit the existing harmonize entry rather than adding a second one.

  • "Dynamic client registration unsupported": check that client_id is under [mcp_servers.harmonize.oauth].

  • Browser can't reach localhost after sign-in: that's normal on a remote VM. Copy the full URL from the address bar and paste it into the terminal prompt of codex mcp login harmonize --no-browser.

  • Signed in but tools won't load: exit and start a fresh Codex session, then check /mcp again.

  • 401 or expired credentials: run codex mcp logout harmonize, then codex mcp login harmonize.

  • 403 or access denied: your Harmonize account doesn't have access to that client. Signing in to OpenAI doesn't grant Harmonize access.

  • Anything else: email [email protected] with the output of codex mcp get harmonize and the time of the attempt.