ExMCP.ACP.Adapters.Codex (ex_mcp v0.9.0)
View SourceAdapter for Codex CLI (OpenAI) using codex app-server persistent mode.
Translates between ACP JSON-RPC and Codex's app-server JSON-RPC protocol. The app-server runs as a persistent subprocess communicating over NDJSON on stdin/stdout, with a JSON-RPC initialize handshake.
Ported from nshkrdotcom/codex_sdk's AppServer.Connection pattern.
Codex App-Server Protocol
- Command:
codex app-server - Handshake:
initializerequest → response →initializednotification - Session:
thread/start→turn/start→ notifications →turn/completed - Notifications: NDJSON events for items, text deltas, reasoning, tool calls, etc.
ACP Mapping
| ACP Message | Codex JSON-RPC |
|---|---|
session/new | thread/start request |
session/load | thread/start with threadId (resume) |
session/prompt | turn/start request |
session/cancel | turn/interrupt request |
item/agentMessage/delta | session/update (text) |
item/reasoning/textDelta | session/update (thinking) |
item/completed (tool) | session/update (tool_call/tool_result) |
item/commandExecution/* | session/update (tool_output) |
turn/completed | prompt response result |
Features
- Initialize handshake with
post_connect/1 - Text and thinking streaming
- Tool call and tool result notifications
- Command execution output streaming
- Token usage tracking
- Turn interrupt/cancel support
- Image content in prompts
Limitations
- No session listing (Codex doesn't expose session enumeration)
- No mode switching (static approval policy at session start)
- No model switching mid-session (set at thread/start)
- No authentication flow (relies on user's local auth)