Skip to main content

Module jsonrpc

Module jsonrpc 

Source
Expand description

Content-Length framed JSON-RPC 2.0 codec.

This is the message framing used by JSON-RPC over stdio transports such as the Model Context Protocol (MCP): each message is prefixed with a Content-Length: N\r\n\r\n header followed by exactly N bytes of UTF-8 JSON body.

The framing codec (read_payload, write_message) is serializer agnostic — it operates on raw strings. The JSON-RPC 2.0 envelope builders (build_result_message, build_error_message, build_notification) are parameterized over a JsonRpcSerializer so this crate does not depend on any concrete JSON value type; the caller binds its own serializer.

Traits§

JsonRpcSerializer
Abstraction over a JSON serializer so the JSON-RPC envelope builders do not depend on a concrete JSON value type.

Functions§

build_error_message
Build a JSON-RPC 2.0 error message.
build_notification
Build a JSON-RPC 2.0 notification (no id, no response expected).
build_result_message
Build a JSON-RPC 2.0 result message.
read_payload
Read a JSON-RPC payload from a buffered reader.
write_message
Write a Content-Length framed JSON-RPC message to a writer.