FastestMCP.PeerTask (fastest_mcp v0.2.0)

Copy Markdown View Source

Handle for a task owned by the connected MCP peer.

This is intentionally distinct from FastestMCP.BackgroundTask, which is local work owned by the FastestMCP runtime, and from FastestMCP.Client.Task, which belongs to a standalone client process. Peer tasks are scoped to the exact server session that created them.

Summary

Functions

Requests cancellation of the peer-owned task.

Fetches the latest task state from the connected peer.

Builds a peer-task handle from validated attributes.

Registers a callback for peer task status changes.

Fetches the peer task's terminal result.

Waits for the peer task to reach a requested or terminal state.

Types

kind()

@type kind() :: :sampling | :elicitation | :generic

t()

@type t() :: %FastestMCP.PeerTask{
  kind: kind(),
  server_name: String.t(),
  session_id: String.t(),
  target: String.t() | nil,
  task_id: String.t()
}

Functions

cancel(task, opts \\ [])

Requests cancellation of the peer-owned task.

fetch(task, opts \\ [])

Fetches the latest task state from the connected peer.

new(attrs)

Builds a peer-task handle from validated attributes.

on_status_change(task, callback)

Registers a callback for peer task status changes.

result(task, opts \\ [])

Fetches the peer task's terminal result.

wait(task, opts \\ [])

Waits for the peer task to reach a requested or terminal state.