Noizu.MCP.JsonRpc (Noizu MCP v0.1.0)

Copy Markdown View Source

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

Functions

decode(binary)

@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!(message)

@spec encode!(message()) :: iodata()

Encode a message struct to wire iodata.

to_map(arg1)

@spec to_map(message()) :: map()

Render a message struct as a plain map (without JSON encoding).