Skip to main content

Module jsonrpc

Module jsonrpc 

Source
Expand description

Shallow JSON-RPC 2.0 envelope.

JsonRpcEnvelope::parse extracts jsonrpc, id, method, params, result, error in one pass. params and result stay as RawValue — unparsed bytes — until a caller opts in to a typed view via JsonRpcEnvelope::params_as or JsonRpcEnvelope::result_as.

JsonRpcEnvelope::to_bytes is the inverse — reassemble the envelope into JSON bytes, typically before forwarding.

MCP 2025-11-25 does not batch, so parse rejects top-level JSON arrays with ParseError::InvalidShape.

Structs§

JsonRpcEnvelope
Shallow parse of a single JSON-RPC 2.0 message.
JsonRpcError
JSON-RPC error object. data stays as raw bytes so middlewares pay no cost when they don’t inspect it.

Enums§

JsonRpcId
JSON-RPC id. Null is valid per spec for replies to un-parseable requests. Absent id (request-without-id, i.e. a notification) is None on the envelope’s id field.
ParseError
Reason JsonRpcEnvelope::parse declined the bytes. These are soft signals for the intake layer — a NotJson body is not an error to the proxy, just a hint to try the next classification branch.