Codex CLI
Connect OpenAI's Codex CLI to TermFlow so it can open terminals, split panes, run commands, and read output through TermFlow's built-in MCP server. This page gives you the exact config.toml block to paste, tells you where that file lives, and explains when the auth token is actually required.
TermFlow must be running, and its MCP server must be healthy. Open Settings → Connections and confirm the health dot is green. By default TermFlow serves MCP at http://127.0.0.1:42032/mcp, bound to 127.0.0.1 (localhost only). You bring your own Codex install and your own model keys — TermFlow ships no AI.
The config block
Codex configures MCP servers in its config.toml. Add this table, exactly as shown:
[mcp_servers.auto-terminal]
url = "http://127.0.0.1:42032/mcp"
http_headers = { "Authorization" = "Bearer <token>" }
env_http_headers = { "X-Termflow-Terminal-Id" = "TERMFLOW_TERMINAL_ID" }
This is the paste-ready output of TermFlow's in-app Connect an AI agent modal (Settings → Connections). Copying it from there fills in your real token automatically.
The server key is the literal string auto-terminal — that is TermFlow's MCP server identifier, and it is what you will see referenced when Codex lists connected servers.
What each line does
| Line | Purpose |
|---|---|
[mcp_servers.auto-terminal] | Registers a streamable-HTTP MCP server under the key auto-terminal. |
url | TermFlow's MCP endpoint. Prod default is http://127.0.0.1:42032/mcp (MCP port 42032). |
http_headers | Static request headers. Here it carries the Authorization: Bearer <token> credential. |
env_http_headers | Headers whose value is read from an environment variable at launch. Here X-Termflow-Terminal-Id is populated from the TERMFLOW_TERMINAL_ID variable. |
env_http_headers maps a header to a variable nameThe right-hand side "TERMFLOW_TERMINAL_ID" is the name of an environment variable, not a literal value and not ${...} syntax. At startup Codex reads the current value of TERMFLOW_TERMINAL_ID from its own environment and sends it as the X-Termflow-Terminal-Id header. See The identity header below for why this matters.
Where Codex reads config.toml
Codex loads configuration from config.toml inside its home directory, CODEX_HOME, which defaults to a .codex folder in your user home:
| Platform | Path |
|---|---|
| Windows | %USERPROFILE%\.codex\config.toml |
| macOS | ~/.codex/config.toml |
| Linux | ~/.codex/config.toml |
If the file does not exist yet, create it. If you have set the CODEX_HOME environment variable to relocate Codex's config, the file lives at $CODEX_HOME/config.toml instead. After editing, restart Codex (or reload its MCP configuration) so it picks up the new server.
When you actually need the token
TermFlow's auth model is deliberately quiet on localhost:
- Default (localhost only): every TermFlow endpoint is unauthenticated. This is safe because the server is bound to
127.0.0.1and never leaves your machine. You can drop thehttp_headersline entirely, or leave the placeholder in — nothing checks it. - Exposed on LAN: if you turn on Expose on local network in Settings → Connections, the bearer token becomes required. Replace
<token>with the value shown in Settings → Connections (the maskedauthTokenfield — use its reveal/copy control).
So the minimal localhost config is simply:
[mcp_servers.auto-terminal]
url = "http://127.0.0.1:42032/mcp"
env_http_headers = { "X-Termflow-Terminal-Id" = "TERMFLOW_TERMINAL_ID" }
The token in Settings → Connections can be rotated at any time (no restart needed for TermFlow's own UI). If you rotate it while exposed on LAN, update the Bearer <token> value in config.toml to match, then restart Codex.
The identity header
When TermFlow spawns a shell, it injects a TERMFLOW_TERMINAL_ID environment variable into that terminal. The env_http_headers line turns that variable into the X-Termflow-Terminal-Id request header, which lets Codex ask MCP tools about its own terminal — for example the get_my_terminal tool, or passing the shorthand "me" wherever a terminal id is expected.
This only carries meaning when Codex is launched from inside a TermFlow terminal pane, because that is where TERMFLOW_TERMINAL_ID is set. If you run Codex in an ordinary terminal outside TermFlow, the variable isn't present, and the self-identification tools simply have nothing to resolve to — the other tools (list, create, execute, read output) still work fine. If you never launch Codex inside TermFlow, you can omit the env_http_headers line.
How the connection flows
Verify it works
- Save
config.tomland restart Codex. - Ask Codex to list your terminals — it should call the
list_terminalsMCP tool and return the terminals currently open in TermFlow. - Ask it to open a terminal and run a command; the new terminal should appear in the TermFlow window.
If Codex reports it cannot reach the server, re-check the health dot in Settings → Connections, confirm the port is 42032, and confirm you are using http://127.0.0.1:42032/mcp (note the /mcp path).
An honest note: hosting an agent inside TermFlow (the ACP direction) is on the roadmap, not shipped. Today the relationship is the other way around — Codex is an MCP client that drives TermFlow. TermFlow bundles no AI and no keys; Codex uses its own.
Next steps
- The MCP server — how the sidecar works and the full list of tools it exposes.
- Local API and auth — the localhost-vs-LAN token model in depth.