ExMCP.ACP.Protocol (ex_mcp v1.0.0-rc.0)
View SourceACP-specific message encoding.
Delegates JSON-RPC 2.0 framing to internal helpers and adds ACP method-specific encoding on top.
ACP uses integer protocol versions (default: 1) rather than MCP's date-based strings.
Summary
Functions
Encodes an agent_message_chunk update notification.
Encodes an agent_thought_chunk update notification.
Encodes an authenticate request.
Encodes an available_commands_update notification.
Encodes a config_option_update notification.
Encodes a current_mode_update notification.
Encodes a JSON-RPC error response.
Encodes an fs/read_text_file request from agent to client.
Encodes a response to a fs/read_text_file request from the agent.
Encodes an fs/write_text_file request from agent to client.
Encodes a response to a fs/write_text_file request from the agent.
Encodes an initialize request.
Encodes an agent initialize response.
Encodes a logout request. Stabilized in ACP spec May 21, 2026.
Encodes a session/request_permission request from agent to client.
Encodes a response to a session/request_permission request from the agent.
Encodes an ACP plan update notification.
Encodes a session/prompt response.
Encodes a JSON-RPC success response.
Encodes a session/cancel notification (no id field).
Encodes a session/close request. Stabilized in ACP spec April 23, 2026.
Encodes a session/delete request. Gated by sessionCapabilities.delete
per https://agentclientprotocol.com/protocol/session-list.
Encodes an unstable session/fork request.
Encodes a session_info_update notification.
Encodes a session/list request. Stabilized in ACP spec March 9, 2026.
Encodes a session/list response.
Encodes a session/load request to load an existing session and replay history.
Encodes a session/new request.
Encodes a session/prompt request.
Encodes a session/new, session/load, or similar session ID response.
Encodes a session/resume request. Stabilized in ACP spec April 22, 2026.
Encodes a session/set_config_option request.
Encodes a session/set_mode request.
Encodes a session/set_model request.
Encodes a stable ACP session/update notification.
Encodes a stable terminal/* request from agent to client.
Encodes a tool_call update notification.
Encodes a tool_call_update notification.
Encodes a usage_update notification.
Generates a unique request ID.
Parses a raw ACP JSON-RPC message with structural validation.
Functions
Encodes an agent_message_chunk update notification.
Encodes an agent_thought_chunk update notification.
Encodes an authenticate request.
ACP v1 authentication uses a "methodId" selected from the agent's
authMethods initialize response. A map may still be passed for adapter
compatibility.
Parameters
method_id_or_params— auth method ID string or full params map
Encodes an available_commands_update notification.
Encodes a config_option_update notification.
Encodes a current_mode_update notification.
Encodes a JSON-RPC error response.
Encodes an fs/read_text_file request from agent to client.
Encodes a response to a fs/read_text_file request from the agent.
Encodes an fs/write_text_file request from agent to client.
Encodes a response to a fs/write_text_file request from the agent.
@spec encode_initialize(map(), map() | nil, pos_integer()) :: map()
Encodes an initialize request.
Parameters
client_info—%{"name" => ..., "version" => ...}capabilities— client capabilities map (optional)protocol_version— integer (default: 1)
@spec encode_initialize_response( integer() | String.t(), map(), map() | nil, [map()] | nil, pos_integer() ) :: map()
Encodes an agent initialize response.
@spec encode_logout() :: map()
Encodes a logout request. Stabilized in ACP spec May 21, 2026.
Encodes a session/request_permission request from agent to client.
Each option's kind must be one of the spec enums
allow_once, allow_always, reject_once, reject_always
per https://agentclientprotocol.com/protocol/tool-calls. Non-spec
values raise ArgumentError — a client receiving an unrecognized
kind cannot render the correct UI affordance.
Encodes a response to a session/request_permission request from the agent.
Encodes an ACP plan update notification.
Encodes a session/prompt response.
Encodes a JSON-RPC success response.
Encodes a session/cancel notification (no id field).
Encodes a session/close request. Stabilized in ACP spec April 23, 2026.
Encodes a session/delete request. Gated by sessionCapabilities.delete
per https://agentclientprotocol.com/protocol/session-list.
Encodes an unstable session/fork request.
cwd is required and must be an absolute path at the client validation
boundary. The request shape matches session/resume.
Encodes a session_info_update notification.
Encodes a session/list request. Stabilized in ACP spec March 9, 2026.
Encodes a session/list response.
Encodes a session/load request to load an existing session and replay history.
cwd is required by the ACP spec
(https://agentclientprotocol.com/protocol/session-setup) and must be an
absolute path string. Passing nil raises FunctionClauseError.
Encodes a session/new request.
cwd is required by the ACP spec
(https://agentclientprotocol.com/protocol/session-setup) and must be an
absolute path string. Passing nil raises FunctionClauseError.
Encodes a session/prompt request.
Encodes a session/new, session/load, or similar session ID response.
Encodes a session/resume request. Stabilized in ACP spec April 22, 2026.
cwd is required (same shape as session/load per
https://agentclientprotocol.com/protocol/session-list). Passing nil
raises FunctionClauseError.
Encodes a session/set_config_option request.
Encodes a session/set_mode request.
Encodes a session/set_model request.
Encodes a stable ACP session/update notification.
Encodes a stable terminal/* request from agent to client.
Encodes a tool_call update notification.
Encodes a tool_call_update notification.
@spec encode_usage_update( String.t(), non_neg_integer(), non_neg_integer(), map() | nil ) :: map()
Encodes a usage_update notification.
Generates a unique request ID.
@spec parse_message(String.t() | map()) :: {:request, String.t(), map(), integer() | String.t()} | {:notification, String.t(), map()} | {:result, any(), integer() | String.t()} | {:error, map(), integer() | String.t() | nil} | {:error, :invalid_message}
Parses a raw ACP JSON-RPC message with structural validation.