Connect Codex
The Codex CLI connects to khive over HTTP in one of two ways: you sign in with your khive account in the browser, or Codex reads an API key from an environment variable each time it starts, so the key never goes into its configuration file.
You need a khive account with a plan. Signing in needs nothing else. An API key comes from the dashboard (see Quickstart, step 1). These steps were tested with Codex CLI 0.162.1.
Sign in with your khive account
Add khive without a key:
codex mcp add khive --url https://khive.ai/v1/mcp
Codex adds khive and starts the sign-in at once:
Added global MCP server 'khive'. Detected OAuth support. Starting OAuth flow… Authorize `khive` by opening this URL in your browser:
Open the URL that follows and sign in to khive with the link or the six-digit code we email you (see Your account). khive then asks you to approve Codex. The page names it as Codex (application host: chatgpt.com, redirecting to: 127.0.0.1) and warns that it is software running on your own machine, because it receives the sign-in at a local address. Click Approve. The browser says Authentication complete, and Codex keeps the sign-in.
Codex waits about five minutes. If the sign-in is not finished by then, the command ends with Error: timed out waiting for OAuth callback, but khive stays added. Sign in with:
codex mcp login khive
It starts the same sign-in and ends with:
Successfully logged in to MCP server 'khive'.
The entry in ~/.codex/config.toml holds only the address. Codex stores the sign-in separately, not in that file. Continue with Make the first call.
Use an API key
1. Put your API key in your environment
export KHIVE_API_KEY="<your API key>"
Add the line to your shell profile (for example ~/.zshrc), so every terminal you start Codex from has the key.
2. Add khive
codex mcp add khive --url https://khive.ai/v1/mcp \ --bearer-token-env-var KHIVE_API_KEY
Codex confirms with Added global MCP server 'khive'. and writes this to ~/.codex/config.toml:
[mcp_servers.khive] url = "https://khive.ai/v1/mcp" bearer_token_env_var = "KHIVE_API_KEY"
The file names the variable, not the key. Codex sends the key as Authorization: Bearer <key>, which khive accepts for an API key. To confirm the entry, run codex mcp list: khive is listed as enabled, with KHIVE_API_KEY as its bearer token variable.
Codex reads KHIVE_API_KEY only when it starts. Started without it, Codex cannot use the khive server you added, so start it again from a terminal where the variable is set.
Make the first call
Start Codex and ask in plain language. Codex picks the tool:
What tasks do I have in khive?
list_tasks { "limit": 200 }A new account has no tasks yet, so the first answer is an empty list.
See your usage
Calls from Codex count against your plan like calls from any other client. https://khive.ai/dashboard/usage shows Requests this month, Usage (month to date) and Top verbs.
Remove khive
codex mcp remove khive
This removes khive from Codex but leaves its access in place. If you signed in, open Review or disconnect apps on your account page and click Revoke access next to Codex (see Your account). If you used a key, open https://khive.ai/dashboard/keys, click Revoke next to it and then Confirm revoke. Calls made with a revoked key are refused.
Questions: contact@khive.ai.