ExMCP.ACP.Adapters.Pi (ex_mcp v0.9.0)
View SourceACP adapter for the Pi coding agent (badlogic/pi-mono).
Translates between ACP JSON-RPC and Pi's RPC NDJSON protocol.
Pi runs as a subprocess in --mode rpc and communicates via
JSONL on stdin/stdout.
Pi RPC Protocol
- Input: JSONL on stdin:
{"type":"prompt","id":"msg-1","message":"..."} - Output: JSONL on stdout with event types: message_update, agent_end, tool_execution_start/update/end, auto_compaction_start/end, etc.
ACP Mapping
| Pi Event | ACP Message |
|---|---|
message_update (text_delta) | session/update notification (text) |
message_update (thinking_delta) | session/update notification (thinking) |
message_update (tool_call) | session/update notification (tool_call) |
tool_execution_start/end | session/update notification (tool_result) |
agent_end | prompt response result |
auto_compaction_* | session/update notification (status) |
Features
- Session persistence via
--session <path>flag - Thinking level control (off/minimal/low/medium/high/xhigh)
- Steering and follow-up message queuing
- Image support with data-url prefix stripping
- Tool execution streaming with progress updates
- Context compaction (manual and auto)
- Session forking and switching
- Model switching mid-session
Configuration
config :arbor_ai, :acp_providers, %{
pi: %{
transport_mod: ExMCP.ACP.AdapterTransport,
adapter: ExMCP.ACP.Adapters.Pi,
adapter_opts: [
cli_path: "pi",
model: "anthropic/claude-sonnet-4-20250514",
thinking_level: "medium",
session_path: "/path/to/session.jsonl"
]
}
}