NexusMCP.JsonRpc (NexusMCP v0.3.0)

Copy Markdown View Source

JSON-RPC 2.0 encode/decode utilities.

Pure functions for parsing incoming requests and building responses.

Summary

Functions

Decode a JSON-RPC 2.0 request from parsed body params (map).

Build a JSON-RPC 2.0 error response.

Returns true if the request is a notification (no id field).

Build a successful JSON-RPC 2.0 response.

Functions

decode(msg)

Decode a JSON-RPC 2.0 request from parsed body params (map).

Returns {:ok, request} or {:error, response}.

error(id, code, message, data \\ nil)

Build a JSON-RPC 2.0 error response.

internal_error_code()

invalid_params_code()

invalid_request_code()

method_not_found_code()

notification?(map)

Returns true if the request is a notification (no id field).

parse_error_code()

result(id, result)

Build a successful JSON-RPC 2.0 response.