Skip to main content

Module framing

Module framing 

Source
Expand description

Newline-delimited JSON-RPC framing for the stdio binding.

Bounded newline-delimited JSON-RPC over a byte stream (SDK-017 R1, the stdio binding SDK-014 R2 names): one message per line, no embedded newline, a line over the limit refused by name and drained so the next line is read whole.

Enums§

FrameError
Why a line could not be read as a message.
Incoming
A message read from the host.

Constants§

INVALID_PARAMS
JSON-RPC’s invalid-params code.
INVALID_REQUEST
JSON-RPC’s invalid-request code.
METHOD_NOT_FOUND
JSON-RPC’s method-not-found code.
PARSE_ERROR
JSON-RPC’s parse error code.
UNSUPPORTED_PROTOCOL_VERSION
MCP 2026-07-28’s unsupported-protocol-version code.

Functions§

error
An error response for id (null when the request’s id could not be read), with optional data.
parse
A JSON value as a JSON-RPC 2.0 request or notification.
read_message
Reads one line of at most limit bytes. Ok(None) is the host closing its end. A line over the limit is drained to its newline and refused.
result
A result response for id.
write_message
Writes one message as one line and flushes it. The message is serialised by serde_json, which never emits a raw newline inside a string.