(sigil mcp protocol)

JSON-RPC 2.0 protocol implementation for MCP.

Provides message parsing, generation, and error handling for the JSON-RPC 2.0 protocol used by MCP.

Exports

Construct a jsonrpc-request struct.

Test if a value is a jsonrpc-request struct.

Get the id field of a jsonrpc-request struct.

Get the method field of a jsonrpc-request struct.

Get the params field of a jsonrpc-request struct.

Get the params field of a jsonrpc-request struct.

Construct a jsonrpc-notification struct.

Test if a value is a jsonrpc-notification struct.

Get the method field of a jsonrpc-notification struct.

Get the params field of a jsonrpc-notification struct.

Get the params field of a jsonrpc-notification struct.

Construct a jsonrpc-response struct.

Test if a value is a jsonrpc-response struct.

Get the id field of a jsonrpc-response struct.

Get the result field of a jsonrpc-response struct.

Get the result field of a jsonrpc-response struct.

Construct a jsonrpc-error-response struct.

Test if a value is a jsonrpc-error-response struct.

Get the id field of a jsonrpc-error-response struct.

Get the code field of a jsonrpc-error-response struct.

Get the message field of a jsonrpc-error-response struct.

Get the data field of a jsonrpc-error-response struct.

The current (stateless) protocol revision. Requests in this era carry their version in _meta on every message and never call initialize.

Revisions reachable only through the legacy initialize handshake, newest first. The head is the fallback offered to a legacy client whose requested version we do not recognise.

Everything this implementation can speak, newest first.

Choose the version to answer a legacy initialize with.

Echoes the client's request when we support it, otherwise offers our newest legacy revision. NEVER answers with mcp-current-version: that revision has no initialize handshake at all, so a legacy client handed it would be looking at a version it cannot speak. A client that asked for a version we do not know is expected to disconnect if it cannot accept the counter-offer.

Parse a JSON-RPC message from a JSON string.

Returns a jsonrpc-request, jsonrpc-notification, or #f on parse error. Does not handle batch requests (arrays).

parse-messageprocedure

Parse a JSON-RPC message from a parsed JSON value (dict).

Returns a JSON-RPC request, notification, response, error response, or #f if invalid. Keeping both directions in this module prevents clients and servers from growing subtly different wire parsers.

Serialize a successful response to JSON string.

Serialize a notification to JSON string.

request->jsonprocedure

Serialize a request to JSON string.

make-responseprocedure

Create a successful response for a request.

Create an error response for a request.

Create a notification (server to client).

(No description)

error-parsevariable

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)