ExMCP.ACP.Adapters.Claude (ex_mcp v0.9.0)

View Source

Adapter for Claude Code CLI.

Translates between ACP JSON-RPC and Claude's stream-json NDJSON protocol. Ported from Arbor's CliTransport + StreamParser.

Claude CLI Protocol

  • Input: NDJSON on stdin with {"type":"user","message":{...},"session_id":"..."}
  • Output: NDJSON on stdout with event types: stream_event, assistant, user, result
  • Args: --output-format stream-json --input-format stream-json --verbose

ACP Mapping

Claude EventACP Message
stream_event (text_delta)session/update notification (text)
stream_event (thinking_delta)session/update notification (thinking)
assistantaccumulate content blocks
assistant (tool_use)session/update notification (tool_call)
user (tool_result)session/update notification (tool_result)
resultprompt response result

Features

  • Session resume via --resume <session_id> flag
  • Thinking block streaming with deduplication
  • Multi-turn tool use cycle tracking
  • Usage tracking with cache token support
  • Configurable thinking budget

Limitations

  • No session persistence/listing (sessions managed by Claude CLI)
  • No mode switching (Claude CLI uses --dangerously-skip-permissions)
  • No session cancel (would need SIGINT to Port subprocess)
  • No runtime config changes (static at launch)