ExMCP.Server.CancellationTracker behaviour (ex_mcp v1.0.0-rc.8)

Copy Markdown View Source

Strategy for propagating notifications/cancelled into handler state.

ExMCP.Server.HandlerServer marks the request cancelled in its own state and then hands the notification to a tracker module so that servers can observe cancellation the way their handler is written. The module is chosen at start-up with the :cancellation_tracker option:

ExMCP.Server.HandlerServer.start_link(
  handler: MyHandler,
  cancellation_tracker: MyApp.CancellationTracker
)

This keeps HandlerServer free of handler-shape-specific branches: it just calls the configured module.

The default implementation is ExMCP.Server.CancellationTracker.Default.

Summary

Callbacks

Records request_id as cancelled and returns the (possibly updated) handler state.

Callbacks

mark_cancelled(request_id, handler_state)

@callback mark_cancelled(request_id :: term(), handler_state :: term()) ::
  handler_state :: term()

Records request_id as cancelled and returns the (possibly updated) handler state.

Implementations run inside the server process, so they must not block.