FastestMCP.Client.Task (fastest_mcp v0.2.0)

Copy Markdown View Source

Connected-client handle for one remote MCP task.

This is intentionally different from %FastestMCP.BackgroundTask{}, which is a local runtime handle. A remote client task is a view over a task owned by a connected peer.

The flow is:

create task remotely
-> register the remote task handle in the client
-> wait on notifications/tasks/status when available
-> fall back to tasks/get polling when needed
-> cache the final tasks/result payload

Summary

Functions

Cancels the remote task and updates the cached status.

Fetches fresh task status from the remote peer and updates the cache.

Registers a callback for task status changes.

Fetches and caches the final result using tasks/result.

Returns the last cached status, if any.

Waits for the task to reach a target state or any terminal state.

Types

kind()

@type kind() :: :tool | :prompt | :resource | :generic

t()

@type t() :: %FastestMCP.Client.Task{
  client: FastestMCP.Client.t(),
  kind: kind(),
  target: String.t() | nil,
  task_id: String.t()
}

Functions

cancel(task, opts \\ [])

Cancels the remote task and updates the cached status.

fetch(task, opts \\ [])

Fetches fresh task status from the remote peer and updates the cache.

on_status_change(task, callback)

Registers a callback for task status changes.

result(task, opts \\ [])

Fetches and caches the final result using tasks/result.

status(task)

Returns the last cached status, if any.

wait(task, opts \\ [])

Waits for the task to reach a target state or any terminal state.