How to Connect Kalen to Codex
To connect Kalen to the Codex CLI, create an API key on the Connect page, put it in an environment variable with export KALEN_API_KEY=<key>, and run codex mcp add kalen --url https://kalen.si/mcp --bearer-token-env-var KALEN_API_KEY. Codex then calls Kalen over streamable HTTP and sends the key as a bearer token from that variable, so the key itself never sits in Codex’s config file. Put the export in your shell profile so every new terminal has it.
Steps
- Sign in to Kalen and open the Connect page.
- Create an API key. It starts with
kln_live_and is shown once: copy it now. You can keep up to 10 active keys and revoke any of them. - Add the key to your shell profile (
~/.zshrcor~/.bashrc), with your key in place of<key>:
export KALEN_API_KEY=<key>
- Open a new terminal, or run
source ~/.zshrc, so the variable is set. - Add Kalen to Codex:
codex mcp add kalen --url https://kalen.si/mcp --bearer-token-env-var KALEN_API_KEY
- Check that Codex lists it:
codex mcp list
- Start Codex and send the prompt below.
Check that it works
Use Kalen to check my account.
Codex should call the account tool and report your plan, credits, X connection and profile. The call shows up on your Usage page.
Example
An illustration, not a real account.
You: Use Kalen to check my account.
Codex calls account. Kalen answers with your plan and balance, whether X is connected (with a connect link to open in your browser if not) and whether your profile, voice and stories are set.
You: Turn the README of this project into an X thread with Kalen.
Codex reads the file, sends its text to Kalen’s repurpose tool, rebuilds it as a thread, checks it, scores it and shows you every tweet. It schedules nothing until you approve.
Media from the terminal
There is no upload panel in a terminal. Kalen’s upload_media returns a curl line instead; run it once per file, then ask Codex to list your media for the ids. See Media and video.
What it costs
The key and the connection are free. Scheduled posts and paid reads from X spend credits, and each asks first. See Credits and plans.
Common errors
- “Missing or invalid Kalen credentials” (HTTP 401). Codex started without the variable, or the key was revoked. Run
echo $KALEN_API_KEYin the same terminal; if it’s empty, set it and restart Codex. If the key was revoked, create a new one on the Connect page and update the export. - Codex doesn’t list Kalen. Run the
codex mcp addcommand again, thencodex mcp list. - A new tool is missing. Codex reads the tool list when it starts. Restart it.
- Never paste the key into a file you commit. Keep it in your shell profile or a secrets manager.
Next
Next: Connect your X account.