JSON-RPC 2.0 framing for MCP.
Pure data layer: decodes a wire binary into one of four message structs and encodes them back. Per MCP 2025-06-18+ JSON-RPC batching is not supported — arrays are rejected as invalid requests.
Summary
Functions
Decode a wire binary into a message struct.
Encode a message struct to wire iodata.
Render a message struct as a plain map (without JSON encoding).
Types
@type message() :: Noizu.MCP.JsonRpc.Request.t() | Noizu.MCP.JsonRpc.Notification.t() | Noizu.MCP.JsonRpc.Response.t() | Noizu.MCP.JsonRpc.ErrorResponse.t()
Functions
@spec decode(binary()) :: {:ok, message()} | {:error, Noizu.MCP.JsonRpc.ErrorResponse.t()}
Decode a wire binary into a message struct.
Returns {:error, %ErrorResponse{}} pre-shaped for replying to the sender when
the payload is malformed (parse error / invalid request).
Encode a message struct to wire iodata.
Render a message struct as a plain map (without JSON encoding).