In-process request helpers for component and protocol tests.
When protocol: is supplied, dispatch/2 adds that dialect's required
request metadata, including protocol version and client capabilities. A real
client must send these fields itself. Use Snodo.Server.dispatch/3 with literal
request maps, transport tests, and an independent client to test wire admission;
passing component tests alone does not establish transport interoperability.
Summary
Functions
Builds one JSON-RPC request and dispatches it with Snodo.Server.dispatch/3
over the :direct transport.
Functions
@spec dispatch(Snodo.Server.Runtime.t(), keyword()) :: Snodo.Server.dispatch_result()
Builds one JSON-RPC request and dispatches it with Snodo.Server.dispatch/3
over the :direct transport.
Options:
:method- the JSON-RPC method. Required.:params- the request params. Defaults to%{}.:id- the request ID. Defaults to1.:protocol- a protocol version enabled inruntime. When set, the dialect's request metadata is added toparams["_meta"](keys already inparams["_meta"]win) and themcp-protocol-versionheader is set. A version the runtime does not enable raisesMatchError. Defaults tonil, which adds neither.:client_capabilities- the client capabilities put in the metadata when:protocolis set. Defaults to%{}.:transport_metadata- the transport context metadata, for example%{auth: principal}, which handlers read ascontext.auth. Defaults to%{}.
Returns what Snodo.Server.dispatch/3 returns: {:ok, response} with the
JSON-RPC response map, or {:stream, subscription} for
subscriptions/listen.
{:ok, %{"result" => result}} =
Snodo.Test.dispatch(MyServer.runtime(),
method: "tools/call",
params: %{"name" => "echo", "arguments" => %{"text" => "hi"}},
protocol: "2026-07-28"
)