codex mcp add --help if flags differ in your version.
Steps
-
Put the key in your shell profile so it survives restarts (an
exporttyped inside an agent’s tool shell is lost when that shell exits, and the client then gets 401):Open a new terminal and startcodexfrom there. -
Add the server. Codex reads the token from the env var named by
--bearer-token-env-var, so the key is not stored in the config: -
Restart Codex, then verify with
codex mcp listor/mcpin the TUI. -
Ask the agent to call
list_channelsand report the channels.
Equivalent config.toml
~/.codex/config.toml (or .codex/config.toml in a trusted project):

