Chuyển đến nội dung chính
Checked against codex-cli 0.167.0 on 2026-11-20. Run codex mcp add --help if flags differ in your version.

Steps

  1. Put the key in your shell profile so it survives restarts (an export typed inside an agent’s tool shell is lost when that shell exits, and the client then gets 401):
    Open a new terminal and start codex from there.
  2. 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:
  3. Restart Codex, then verify with codex mcp list or /mcp in the TUI.
  4. Ask the agent to call list_channels and report the channels.

Equivalent config.toml

~/.codex/config.toml (or .codex/config.toml in a trusted project):

Troubleshooting