yera.tools.mcp.task
Public lifecycle values for MCP tasks.
Symbols
MCPTask
Generic[ResultT]Represent an immediate or server-backed MCP tool execution.
Methods
MCPTask.__init__
__init__(
state: MCPTaskState,
value: object = _MISSING,
refresh: _TaskRefresher | None = None,
update: _TaskUpdater | None = None,
cancel: _TaskCanceller | None = None,
) → NoneCreate a task handle from its current state.
Parameters
Most recently observed task lifecycle state.
Converted result for an already-completed task.
Operation used to retrieve updated server task state.
Operation used to submit requested task input.
Operation used to request server-side cancellation.
MCPTask.async_refresh
async_refresh() → MCPTaskStateRefresh and return the latest server-reported task state.
Returns
The latest immutable task state. Immediate tasks retain their completed local state.
Raises
If a server-backed task has no refresh operation.
MCPTask.async_cancel
async_cancel() → MCPTaskStateCancel this server-backed task and return its resulting state.
Returns
The task state observed after the server acknowledges cancellation.
Raises
If the task is already complete or cannot be cancelled.
MCPTask.async_update
async_update(
input_responses: InputResponses,
) → MCPTaskStateSubmit requested input and return the resulting task state.
Parameters
Responses keyed by outstanding request identity.
Returns
The task state observed after the server accepts the responses.
Raises
If this task is not awaiting input or cannot be updated.
MCPTask.async_wait
async_wait() → ResultTWait for completion and return the converted tool result.
Returns
The converted result of the completed task.
Raises
If the task requires user input before it can continue.
If the task reaches a terminal state without a converted result.
If the server reports an error while executing the task.
MCPTask.refresh
refresh() → MCPTaskStateRefresh and return the latest server-reported task state.
Returns
The latest immutable task state.
Raises
If a server-backed task has no refresh operation or the server returns state for a different task.
MCPTask.cancel
cancel() → MCPTaskStateCancel this server-backed task and return its resulting state.
Returns
The task state observed after the server acknowledges cancellation.
Raises
If the task is already complete or cannot be cancelled.
MCPTask.update
update(
input_responses: InputResponses,
) → MCPTaskStateSubmit requested input and return the resulting task state.
Parameters
Responses keyed by outstanding request identity.
Returns
The task state observed after the server accepts the responses.
MCPTask.wait
wait() → ResultTWait synchronously for completion and return the converted result.
Returns
The converted result of the completed task.
Raises
If the task requires user input before it can continue.
If the task reaches a terminal state without a converted result.
If the server reports an error while executing the task.
MCPTaskState
Describe one observed state of a server-backed MCP task.
Fields
Stable identifier minted by the MCP server.
Current lifecycle status.
Optional human-readable detail supplied by the server.
Time at which the server created the task.
Time at which the server last updated the task.
Retention duration from creation, or None when unlimited.
Server-recommended delay between status requests.
Methods
MCPTaskState.__init__
__init__(
task_id: str | None,
status: MCPTaskStatus,
status_message: str | None,
created_at: datetime,
last_updated_at: datetime,
ttl: timedelta | None,
poll_interval: timedelta | None,
) → None