ExperimentalZod schema type for input validation (inferred)
MCP Tasks is an experimental SDK feature
ExperimentalcreateCreate and start a new task.
Called when the client issues a tools/call with task parameters.
Should initiate the background work and return immediately.
Validated input (typed from Zod schema)
Task creation context with taskStore
Object containing the created task
ExperimentalgetGet the current status of a task.
Called when the client polls via tasks/get.
Return the task with its current status.
Original tool input args
Task operation context with taskId and taskStore
Task status result
ExperimentalgetGet the final result of a completed task.
Called when the client requests the result via tasks/result.
Should return the tool's final output.
Original tool input args
Task operation context with taskId and taskStore
MCP CallToolResult (use response helpers: text(), json(), error())
Handler interface for task-based tool execution.
Task tools use a three-method handler instead of a single callback, enabling long-running operations with a create → poll → result lifecycle:
createTask— Initiate the task, return immediately with a task IDgetTask— Return current task status (clients poll this)getTaskResult— Return the final result when the task completesExample