Topic 3 of 5 · 6 min read
Long-running work with the MCP Tasks extension
Goal: Decide which tools should return tasks and trace a task from creation through input_required to completion or failure.
A tool that may run for minutes should return a durable task handle instead of holding the connection open; the client polls the task, answers any questions it raises, and reads the result when it finishes. Tasks live in an official extension named io.modelcontextprotocol/tasks, not in the core protocol.
Check yourself · 1 of 3
A tool call returns a CreateTaskResult with a taskId. What should the client do next?
Why it matters
A CI pipeline, a batch export or an approval step can take far longer than a connection or a proxy timeout. If the client disconnects, blocked work is lost to it. A task ID is a durable handle: after a crash or restart the client resumes with the same ID. The overview also lists status messages for progress, and mid-flight input without a second connection.
How it works
- Opt in. The client lists
io.modelcontextprotocol/tasksin its per-request capabilities, and the server advertises it inserver/discover. - The server decides. For a supported request such as
tools/call, the server may return aCreateTaskResult(resultType: "task") with ataskId, a status, a TTL and a polling interval. A client must therefore handle two result shapes for the same call. - Poll. The client calls
tasks/getwith thetaskIdand respectspollIntervalMs. Servers can also sendnotifications/tasksto clients that subscribed. - Answer questions. If the status is
input_required, thetasks/getresponse includesinputRequests. The client responds withtasks/update. - Finish.
completedcarries theresultthe call would have returned.failedcarries the JSON-RPCerror.cancelledis the third end state. All three are terminal and never change again. - Cancel.
tasks/cancelis a request, not a command: the server may keep working.
Which tools return tasks
Return a task when the work can take longer than a few seconds, needs a human approval gate, or must survive a reconnect. Keep fast lookups synchronous. A tool that always returns a task for a 50 ms read only adds polling.
Before and after
Weak: run_pipeline blocks for 12 minutes. The proxy times out at 60 seconds and the user sees an error while the pipeline keeps running.
Fixed: it answers at once.
{ "resultType": "task", "taskId": "t_7f2", "status": "working", "pollIntervalMs": 5000 }
The client polls tasks/get every 5 seconds and reads the final result when the status is completed.
What goes wrong
- Ignoring the interval. Polling every 100 ms against a server that asked for 5000 wastes both sides.
- Losing the ID. A client that keeps the
taskIdonly in memory cannot resume. - Assuming cancel stopped it. Check the final status before telling the user that nothing ran.
Examples
A deploy with an approval gate
tools/call deploy -> task t_91, working
tasks/get t_91 -> working, "building image"
tasks/get t_91 -> input_required, inputRequests: { approve: elicitation "Deploy to production?" }
tasks/update t_91 -> inputResponses: { approve: { action: "accept" } }
tasks/get t_91 -> working, "rolling out"
tasks/get t_91 -> completed, result: { url: "https://app.example.com" }
The approval needed no second connection, and the user could close the laptop between steps.
Choosing per tool
get_build_status returns in 40 ms and stays synchronous. export_all_invoices takes 2 to 20 minutes depending on the account, so the server returns a task when the estimate is long and answers directly when the account is small. The client code handles both.
Key points
- A task is a durable handle, so a client can resume polling after a disconnect or restart.
- The server decides per request whether to return a task, and the client must handle both result shapes.
- The statuses are working, input_required, completed, failed and cancelled, and the last three are terminal.
- Questions during a task arrive in inputRequests on tasks/get and are answered with tasks/update.
- tasks/cancel is cooperative, so the server is not obliged to stop the work.
- Return tasks for long, approval-gated or reconnect-sensitive work and keep quick reads synchronous.
Common mistakes
- Holding the connection open for slow work and relying on a long timeout.
- Treating a task result as the final tool result without checking the status.
- Polling faster than the server's suggested interval.
- Treating a cancelled task as proof the work never ran.
Check yourself · 2 of 3
Which statuses are terminal for an MCP task?
Check yourself · 3 of 3
A task reaches input_required with an approval question. How does the client answer it?
Practice items, not counted towards your mastery.
Start here
- MCP elicitation specification (2026-07-28) (opens in a new tab)StandardFree
The normative rules for form and URL mode, the flat schema subset and what clients must show the user.
- MCP multi round-trip requests (2026-07-28) (opens in a new tab)StandardFree
Defines InputRequiredResult, inputRequests, inputResponses and the integrity rules for requestState.
- MCP Tasks extension overview (opens in a new tab)DocsFree
Task lifecycle, tasks/get polling, tasks/update input and when a server should return a task.
More for this topic
- MCP Tasks extension repository (opens in a new tab)ToolFree
The full specification and the discussion behind the extension.