fastmcp.client.tasks
SEP-1686 client Task classes.
Classes
TaskNotificationHandler
MessageHandler that routes task status notifications to Task objects.
Methods:
dispatch
Task
Abstract base class for MCP background tasks (SEP-1686).
Provides a uniform API whether the server accepts background execution
or executes synchronously (graceful degradation per SEP-1686).
Methods:
task_id
returned_immediately
- True if server executed synchronously (graceful degradation or no task support)
- False if server accepted background execution
on_status_change
callback: Function to call with GetTaskResult when status changes. Can return None (sync) or Awaitable[None] (async).
status
result
wait
state: Desired state (‘submitted’, ‘working’, ‘completed’, ‘failed’). If None, waits for any terminal state (completed/failed)timeout: Maximum time to wait in seconds
- Final task status
TimeoutError: If desired state not reached within timeout
cancel
ToolTask
Represents a tool call that may execute in background or immediately.
Provides a uniform API whether the server accepts background execution
or executes synchronously (graceful degradation per SEP-1686).
Methods:
result
- The parsed tool result (same as call_tool returns)
PromptTask
Represents a prompt call that may execute in background or immediately.
Provides a uniform API whether the server accepts background execution
or executes synchronously (graceful degradation per SEP-1686).
Methods:
result
- The prompt result with messages and description
ResourceTask
Represents a resource read that may execute in background or immediately.
Provides a uniform API whether the server accepts background execution
or executes synchronously (graceful degradation per SEP-1686).
Methods:
result
- list[ReadResourceContents]: The resource contents

