mcp.protocol.jsonrpc

Undocumented in source.

Members

Enums

MessageKind
enum MessageKind

What a JSON-RPC message represents.

Functions

makeErrorResponse
Json makeErrorResponse(Json id, McpException e)

Build an error response object from an McpException.

makeNotification
Json makeNotification(string method, Json params)

Build a notification object (no id).

makeRequest
Json makeRequest(Json id, string method, Json params)

Build a request object.

makeResponse
Json makeResponse(Json id, Json result)

Build a success response object.

parseAny
ParsedInput parseAny(string text)

Parse text that may be either a single message or a batch array.

parseBatch
deprecated Message[] parseBatch(string text)

Parse a JSON-RPC batch (array) from text.

parseBatchTolerant
BatchResult parseBatchTolerant(string text)

As parseBatch, but tolerant of individual malformed members (see parseBatch).

parseMessage
Message parseMessage(string text)

Parse and classify a single JSON-RPC message from text.

rpcIdString
string rpcIdString(Json id)

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.

Structs

BatchMemberError
struct BatchMemberError

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.

BatchResult
struct BatchResult

parseBatch result that keeps malformed members rather than discarding the whole batch.

Message
struct Message

A classified JSON-RPC message wrapping its raw Json.

ParsedInput
struct ParsedInput

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.