Skip to main content
Codex CLI reads its MCP servers from a TOML config file, or accepts them through its own mcp subcommand.

Add the server

Codex reads the key from an environment variable and adds the Bearer prefix itself, so the key never lands in the config file. Export it in your shell profile:
Then register the server with the CLI:
Or edit ~/.codex/config.toml directly:
~/.codex/config.toml
codex mcp add has no --header flag. To pass the key inline instead of through a variable, use the config file: put http_headers = { "Authorization" = "Bearer 2xt_YOUR_API_KEY" } under [mcp_servers.2extract] in place of bearer_token_env_var.

Verify

2extract should be listed. Then start Codex and ask:
What is my 2extract balance?
A number comes back, and no proxy was created.

Troubleshooting

Run codex mcp list. If the entry is missing, the config file was not picked up - confirm the path is ~/.codex/config.toml and that the TOML parses.If the entry is there but not connecting, update Codex: older builds had no remote HTTP transport. Check codex mcp --help.
With bearer_token_env_var, the variable must be set in the shell that starts Codex. Run echo $EXTRACT_API_KEY there; an empty line means Codex sends no key. The variable holds the bare key (2xt_...) - Codex adds Bearer itself.With http_headers, keep the whole value in one quoted string, including the word Bearer.
A scope problem rather than a connection problem. The key is missing the scope those tools need - see Overview.

Next steps

Tools

Everything the agent can call.

Other clients

The three values any MCP client needs.