Expand description
Shared JSON-RPC 2.0 codec.
One set of wire types serves three surfaces: the MCP client (to external
servers), the self-MCP server, and the private supervisor↔subagent
control channel. They differ only in framing (see frame): MCP stdio
is newline-delimited; the control channel is length-prefixed.
Keeping every wire type behind serde in this one module is deliberate: it
is the single isolation point from which the codec could be swapped to a
lighter encoder (e.g. miniserde) without touching call sites, should the
proc-macro compile weight ever need to come out of the dependency budget.
Modules§
- frame
- Two framings over a byte stream, sharing the JSON-RPC codec in the parent
module (
crate::rpc).
Structs§
- Notification
- A JSON-RPC 2.0 notification (no
id; no response). - Request
- A JSON-RPC 2.0 request (has an
id; expects a response). - Response
- A JSON-RPC 2.0 response (exactly one of
result/error). - RpcError
- A JSON-RPC 2.0 error object. Distinct from a successful result that
carries
isError: true— the latter is a tool-domain failure fed back to the model as an observation, the former is a protocol/transport failure. That distinction is load-bearing in the loop: anisErrorresult keeps the conversation going, anRpcErroraborts the call. - Version
- The literal
"2.0". A newtype so a malformedjsonrpcfield is a parse error, not a silent mismatch.
Enums§
- Id
- JSON-RPC request/response id. Spec allows string or number (and, in responses to a parse error, null). We never send a null id.
- Incoming
- Any inbound JSON-RPC frame, before we know which kind it is. A reader thread parses one of these per frame and dispatches: responses resolve a pending request by id; notifications fan out to handlers; requests (only on the server side / sampling-style server→client) are answered.
Constants§
- INTERNAL_
ERROR - INVALID_
PARAMS - INVALID_
REQUEST - METHOD_
NOT_ FOUND - PARSE_
ERROR - RESOURCE_
NOT_ FOUND - MCP server-defined: a
resources/readfor a URI the server doesn’t have.