arizona_jsonrpc (arizona v0.4.0)
View SourceJSON-RPC 2.0 envelope codec.
Pure, transport-free helpers shared by the MCP transport
(arizona_mcp_handler): decode a request body into a normalized
message, and build the success / error response objects.
A decoded message is #{method := binary(), params := map(), id := id()}.
An absent (or null) id decodes to undefined, marking a
notification -- a message the server must never reply to. A present id
that is neither a string nor an integer (MCP's two request-id types) is an
invalid request, not a notification, so its sender still gets an answer.
Only single messages are decoded; a top-level JSON array (a JSON-RPC
batch) decodes to {error, invalid_request}. Batch support was
dropped from the MCP protocol, so a single-message codec is current.
Error codes follow the JSON-RPC 2.0 spec:
| Code | Meaning |
|---|---|
-32700 | Parse error -- invalid JSON |
-32600 | Invalid Request -- not a well-formed request object |
-32601 | Method not found |
-32602 | Invalid params |
-32603 | Internal error |
Summary
Functions
Decode a request body into a normalized JSON-RPC message.
Build a JSON-RPC error response object (no data member).
Build a JSON-RPC notification object -- a request with no id, which the
peer never answers. Used for server-initiated notifications/* messages.
Build a JSON-RPC success response object.
Types
Functions
-spec decode(Body) -> {ok, request()} | {error, parse_error | invalid_request} when Body :: iodata().
Decode a request body into a normalized JSON-RPC message.
Returns {error, parse_error} for invalid JSON, or
{error, invalid_request} for valid JSON that is not a well-formed
JSON-RPC 2.0 request object (wrong/absent jsonrpc version, a
non-binary or absent method, a non-object params, a present id
that is neither a string nor an integer, or a top-level array).
Build a JSON-RPC error response object (no data member).
Build a JSON-RPC notification object -- a request with no id, which the
peer never answers. Used for server-initiated notifications/* messages.
Build a JSON-RPC success response object.