Anubis. Server. Session. ServerRequests
(anubis_mcp v1.14.0)
Copy Markdown
Engine for server-initiated requests (sampling, roots, elicitation).
Owns the lifecycle of requests the server sends to the client: capability validation, encoding, transport send, timeout tracking, and routing the response back to the server module callback. The three subsystems share one generic flow; what varies between them (wire method, client capability, timeout message, result shaping, log events) lives in the per-kind configuration below.
State is kept in the Session's server_requests map; this module
transforms it and performs the side effects (timers, transport, logging)
at the edges. Anubis.Server.Session delegates to this module and
supplies a frame_fn to prepare the callback frame lazily.
Summary
Functions
Handles a client error response for a tracked server-initiated request.
Routes a client response for a tracked server-initiated request.
Handles a timeout for a tracked server-initiated request.
Sends a server-initiated request of the given kind to the client.
Returns true if the given request ID belongs to a tracked server-initiated request.
Types
@type frame_fn() :: (state() -> Anubis.Server.Frame.t())
@type kind() :: :sampling | :roots | :elicitation
@type state() :: map()
Functions
Handles a client error response for a tracked server-initiated request.
Routes a client response for a tracked server-initiated request.
Stops the timeout timer, untracks the request, shapes the result per the
kind configuration, and invokes the configured server module callback
with the frame built by frame_fn.
Handles a timeout for a tracked server-initiated request.
Kinds configured with cancel_on_timeout first attempt to notify the
client with notifications/cancelled before dropping the request.
Sends a server-initiated request of the given kind to the client.
Generates the request ID, arms the timeout timer, tracks the request in
state.server_requests, validates the client capability, and encodes and
sends the request. On any failure the timer is cancelled and the request
untracked. extra is merged into the tracked request info (elicitation
uses it for the requested_schema needed to validate the response).
Returns true if the given request ID belongs to a tracked server-initiated request.