Codex

Connect OpenAI Codex to Ternary MCP with codex mcp add, browser OAuth, and optional TOML configuration.

Connect OpenAI Codex to Ternary from the command line. Codex can access the full current Ternary MCP tool set, including ad-hoc cost queries, budgets, dashboards, cost alerts, reports, savings recommendations, and AI spend against revenue.

Before you start

You need:

  • An existing Ternary account
  • Access to at least one Ternary tenant
  • OpenAI Codex version 0.148.0 or later

Earlier Codex versions cannot complete the Ternary sign-in flow.

Step 1: Add the Ternary MCP server

Open a terminal on your machine. Paste one of the commands below and press Enter.

Run this in your shell, not as a message inside a Codex session. If Codex is already open, use a separate terminal window.

Choose the tab that matches where your Ternary tenant is hosted:

codex mcp add ternary --url https://core-api.ternary.app/mcp
⚠️

Type the URL exactly

Codex identifies the MCP server by the exact URL. A URL ending in /mcp/ may be treated as a different server and can cause sign-in to fail.

Step 2: Sign in

After you add the server, Codex detects the authentication requirement and opens Ternary in your browser.

  1. Sign in with your normal Ternary credentials.
  2. Approve the access request.
  3. Return to Codex.

The session is remembered between runs. If the browser does not open, or you need to authenticate again later, run:

codex mcp login ternary

Optional: configure Codex manually

You can also add Ternary directly to ~/.codex/config.toml.

[mcp_servers.ternary]
url = "https://core-api.ternary.app/mcp"

Ask your first question

Try:

What did we spend last month, grouped by provider?

Which budgets are at risk?

List recent cost alerts.

Show our largest current savings recommendations.

Codex can choose the appropriate Ternary tools based on your request.

Permissions and writes

Every request runs with your existing Ternary permissions.

Most current MCP capabilities are read-only. Creating a private report is the only current Ternary MCP write action, and it should only happen when you explicitly ask Codex to save an analysis.

Codex connects to the Ternary server each time it starts, so a new session picks up new tools on its own. If Codex reports the Ternary server as unauthorized, run codex mcp login ternary again.

Troubleshooting

Sign-in fails with Unknown client

Check that the MCP URL is written exactly as documented and does not end with a trailing slash.

Sign-in fails or loops

Make sure your Ternary user exists in the same region as the MCP server URL.

No tenants appear

Ask your Ternary administrator to confirm that your user has an explicit role on at least one tenant.

See Troubleshooting Ternary MCP for shared issues.


Did this page help you?