Skip to main content

Overview

Connecting an AI agent to TermFlow means pointing an MCP client at TermFlow's built-in MCP server so the agent can open terminals, split panes, run commands, and read output. This page shows the authoritative way to do it and where each client's step-by-step guide lives.

TermFlow ships no AI and sells no AI usage — you bring your own agent and your own keys. Agents connect as clients over the Model Context Protocol; TermFlow is the terminal they drive.

The One Server URL You Need​

Every MCP client connects to the same local endpoint:

http://127.0.0.1:42032/mcp
  • 42032 is the default MCP port for the installed app (the REST + WebSocket API runs separately on 42031).
  • The server speaks streamable HTTP — a single /mcp endpoint handling POST, GET (SSE), and DELETE.
  • Both the host and port are overridable in Settings → Connections. If you change the MCP port, use your value in the URL above.
Connection Details

Don't hand-write the config from memory. TermFlow generates it for you — read on.

The Authoritative Way: The Connect Modal​

The source of truth for connection config is the in-app Connect modal:

Settings → Connections → "Connect an AI agent ⓘ"

The modal generates paste-ready configuration for your client, already filled in with your current host, port, and auth token. This matters because the exact key names, header shapes, and token differ per client — copying from the modal removes the guesswork.

The dialog title is Connect an AI agent (MCP). Choose a reachable address under Interface, choose your client under Agent, then click Copy. Click Done to close it.

Connection Details

The modal lives inside the Connections settings tab, alongside the port fields, the "Expose on local network" toggle, and the auth token controls. See Settings → Connections & Network for the full panel.

Four First-Class Clients​

TermFlow generates config for four clients. Every generated config uses the server key termflow and includes both Authorization: Bearer <token> and X-Termflow-Terminal-Id.

ClientConfig FileGuide
Claude Code.mcp.jsonClaude Code
Codexconfig.tomlCodex
Antigravity CLImcp_config.jsonAntigravity CLI
GitHub Copilot CLI~/.copilot/mcp-config.jsonGitHub Copilot CLI

Claude Code uses type: "http", url, and headers. Codex uses a TOML table with url, enabled, http_headers, and env_http_headers. Antigravity CLI uses serverUrl and headers; GitHub Copilot CLI uses type: "http", url, and headers.

Manual Clients​

Other clients need manual setup for the same streamable-HTTP endpoint, with authentication headers when required. See Other MCP Clients and Gemini CLI Manual Setup. The app no longer generates Gemini CLI config; the config source describes Antigravity CLI as its successor.

Authentication: Usually Nothing to Do​

In the default localhost-only mode, the MCP server is bound to 127.0.0.1 and every endpoint is unauthenticated. This is safe precisely because it is reachable only from your own machine — no token is required to connect.

Authentication is enforced only when you turn on "Expose on local network" in Settings → Connections. In that mode the server binds to 0.0.0.0 and every request must carry a Bearer token:

Authorization: Bearer <token>

The real credential is the authToken shown (masked, with reveal / copy / rotate) in Settings → Connections — the same token the Connect modal drops into your generated config. The generated config includes the token even on localhost. Treat the copied block as a secret; after rotating the token, copy it again and update your client.

Connection Details

The Authorization header is optional on localhost and required once you expose the server on your LAN. If a remote agent gets 401/403, it's almost always a missing or stale Bearer token — re-copy the config from the modal after rotating.

For the full auth model — how the token is generated, when it's checked, and how rotation behaves — see Local API & Auth.

The Identity Header: How an Agent Finds "Its Own" Terminal​

When an agent runs inside a TermFlow terminal, that terminal injects a $TERMFLOW_TERMINAL_ID environment variable. Passing it back to the server via the identity header lets the agent identify the terminal it's living in:

X-Termflow-Terminal-Id: ${TERMFLOW_TERMINAL_ID}

With this header set, the agent can call the get_my_terminal tool — or use the "me" shorthand anywhere a terminal id is expected — to read, write, or close its own terminal without first listing and guessing which one it is.

  • Claude Code carries this header in its generated config (it expands ${VAR}).
  • Codex injects it via env_http_headers.
  • Antigravity CLI and GitHub Copilot CLI include ${TERMFLOW_TERMINAL_ID} in this header. Their header variable expansion is unconfirmed in the config source. If it does not expand, pass the terminal ID explicitly to tools instead of using "me".

How It Fits Together​

The agent talks only to the MCP server; the server bridges to TermFlow's local API, which owns the actual terminals and panes.

Prefer Raw HTTP Instead?​

If you're building your own orchestrator rather than connecting an existing agent, you can skip MCP entirely and drive TermFlow over its REST + WebSocket API. See The REST/WS alternative.

Next Steps​