What a JSON-RPC message represents.
Build an error response object from an McpException.
Build a notification object (no id).
Build a request object.
Build a success response object.
Parse text that may be either a single message or a batch array.
Parse a JSON-RPC batch (array) from text.
As parseBatch, but tolerant of individual malformed members (see parseBatch).
Parse and classify a single JSON-RPC message from text.
Render a JSON-RPC request id (a string or a number per the spec) to a stable string form. Used where an id must be carried as a string value — e.g. the draft subscriptions/listen id stamped into outbound notifications' _meta["io.modelcontextprotocol/subscriptionId"]. A string id is returned verbatim; a numeric id is rendered as its decimal text; anything else (null / absent) yields an empty string.
A malformed batch member: its position in the array, the raw member item, and the validation error. The raw item is retained so a dispatcher can recover the member's id (which may still be present even when the envelope is invalid) and resolve a pending request rather than letting it time out.
parseBatch result that keeps malformed members rather than discarding the whole batch.
A classified JSON-RPC message wrapping its raw Json.
Result of parseAny: a single message or a batch, normalized to a list. For a batch, errors carries any malformed members (empty otherwise) so the dispatcher can emit a distinct id:null error per malformed member.