Pure JSON-RPC 2.0 codec for the in-house MCP client (SPEC §2).
Framing/correlation helpers plus the MCP methods toolnexus speaks:
initialize, notifications/initialized, tools/list (cursor pagination),
tools/call, inbound ping, and the inbound elicitation/create bridge
onto §10 Request/Answer (mirrors js/src/mcp.ts elicitationToRequest /
answerToElicitResult exactly).
Summary
Functions
Map a resolved §10 Answer back onto an MCP elicit result:
ok → accept (with answer.data as content); reason=="declined" → decline;
everything else → cancel.
Classify a decoded inbound message:
{:request, id, method, params} (server→client request, e.g. ping/elicitation),
{:response, id, {:ok, result} | {:error, error}}, {:notification, method, params},
or :unknown. Unknown notifications are tolerated silently by the caller.
clientInfo version — the toolnexus app version from mix.
Map an MCP elicitation/create request onto a §10 Request:
form mode → kind:"input" (with requestedSchema carried in data.schema);
URL mode (mode == "url") → kind:"authorization" with url.
Encode a message as one newline-delimited JSON line (stdio framing).
initialize params. When elicitation? the client advertises the
elicitation capability so servers may elicit (§2 elicitation bridge);
without a waitFor the capability is not advertised and a compliant server
will not elicit.
Reply to an inbound ping.
The MCP protocol version this client advertises.
Functions
Map a resolved §10 Answer back onto an MCP elicit result:
ok → accept (with answer.data as content); reason=="declined" → decline;
everything else → cancel.
Classify a decoded inbound message:
{:request, id, method, params} (server→client request, e.g. ping/elicitation),
{:response, id, {:ok, result} | {:error, error}}, {:notification, method, params},
or :unknown. Unknown notifications are tolerated silently by the caller.
clientInfo version — the toolnexus app version from mix.
Map an MCP elicitation/create request onto a §10 Request:
form mode → kind:"input" (with requestedSchema carried in data.schema);
URL mode (mode == "url") → kind:"authorization" with url.
Encode a message as one newline-delimited JSON line (stdio framing).
initialize params. When elicitation? the client advertises the
elicitation capability so servers may elicit (§2 elicitation bridge);
without a waitFor the capability is not advertised and a compliant server
will not elicit.
Reply to an inbound ping.
The MCP protocol version this client advertises.