Tasks: io.modelcontextprotocol/tasks extension on modern servers (era fork)#1731
Conversation
Core + test-server implementation of the SEP-2663 tasks extension for modern (2026-07-28) connections, forked from the legacy 2025-11-25 tasks path. SDK v2 removed all tasks support AND era-gates the tasks/* spec methods out of the modern era on both the client (outbound) and server (inbound) sides, and its codec rejects a resultType:"task" result outright. So the Inspector drives the extension itself: task creation rides tools/call (a modern method) with the resultType:"task" frame rewritten at the transport to a CallToolResult carrying the handle in _meta; tasks/get/update/cancel go over a raw-wire request channel that bypasses the era gate (full modern envelope, string ids, consumed by the transport). input_required tasks reuse the existing pending-request modal via fulfilInputRequests, answered with tasks/update. No tasks/list, no tasks/result. Tab + run-as-task gate on the negotiated extension; the managed task store's refresh re-polls known handles on modern (no server list). Test server serves the extension via an Express interceptor (SDK can't) + a shared poll-driven runtime. Full integration coverage of both eras. Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
Adds unit coverage for modernTaskSchemas and the raw-wire request channel (transport-null guard, send failure, timeout, error response, teardown), plus end-to-end era integration tests (create/poll/input-required/update/cancel, synchronous passthrough, unknown-id error, modern store re-poll). Fixes the App and constructor-capabilities tests for the always-on tasks extension. Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
Document the tasks era-fork test configs in README and the new core/test-server files in AGENTS.md. Share one modern + one legacy test server across the era integration block (started lazily, stopped in afterAll) — starting a fresh Express server per test made connection negotiation flaky under the heavy concurrent coverage run. Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
The logging/subscriptions PR screenshots + README were staged-deleted in the working tree before this branch; restore them from v2/main so this PR doesn't remove other PRs' artifacts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
On modern (SEP-2663) task creation is server-directed — the client declares the extension once and any tool may return a task — so the Tools screen now offers 'Run as task' for every tool on a modern connection (threaded via a modernTasks prop through InspectorView → ToolsScreen → ToolDetailPanel), rather than gating on the legacy per-tool taskSupport. Verified end-to-end in the web UI (remote proxy): create → poll tasks/get → input_required elicitation → tasks/update → inline result, plus the unchanged legacy tasks/list/result flow. Adds proof screenshots. Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
…path auto-poll) 1. The pending-request note now distinguishes a modern task round from an MRTR round: a new 'task-input-required' PendingRequestOrigin threads through fulfilInputRequests → the pending-request modal → MrtrOriginNote, which shows 'submitted via a tasks/update request (SEP-2663), not a retry' instead of the MRTR retry copy. 2. The ordinary (non-run-as-task) modern callTool path now auto-polls an unsolicited task handle: attemptToolCall detects the rewritten handle in the result _meta and drives it to termination (get → input_required/update → inline result), dispatching task events so the Tasks tab + toasts track it and the tool result resolves to the task's final result. The poll loop is shared with the streaming path via extracted helpers (submitModernTaskInput / modernTaskTerminalOutcome / modernTaskPollInterval). Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
|
@claude review |
|
Claude finished @cliffhall's task in 3m 9s —— View job Review: Tasks extension on modern servers (era fork)Read the core ( Overall this is excellent work — the transport-rewrite + raw-wire approach is a clean way to route an extension the SDK actively blocks, the "log the true frame, hand the SDK a benign one" ordering is exactly right for keeping the Protocol/Network tabs honest, and the shared poll helpers ( Observations / suggestions
Things I verified are not problems
Todo
|
…round cap, clarifying comment) + fresh smoke screenshots Review of #1731: 1. withModernTaskEnvelope now stamps the NEGOTIATED protocol version (getProtocolVersion() ?? MODERN_PROTOCOL_VERSION) so the envelope matches the MCP-Protocol-Version header instead of a hardcoded constant. 2. A never-completing input_required task is now bounded by MRTR_MAX_ROUNDS in the shared submitModernTaskInput (threaded through both poll loops), so a non-conformant server can't re-prompt the user forever. New modern_loop_task test-server tool + integration test cover the cap. 3. ToolDetailPanel: comment clarifying that per-tool taskSupport:"forbidden" is deliberately ignored on modern (task creation is server-directed under SEP-2663). (The abort-during-poll observation is addressed in the PR reply: the cancel path uses tasks/cancel and disconnect rejects the in-flight raw request, so the poll stops; matches legacy.) Fresh web-UI smoke screenshots (modern connected, task completed, input_required with the corrected tasks/update note, input completed). Refs #1631 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
|
Thanks for the thorough review! Addressed all four observations — three with code, one with reasoning. 1. Envelope 2. Poll loops don't honor a signal abort → confirmed acceptable, left as-is (matches legacy). Walking the real cancel/disconnect paths:
So the signal-aborted-but-still-polling case doesn't arise in the actual flows, and this matches the legacy 3. Stuck 4. Also re-verified end-to-end in the web UI after the changes (fresh screenshots in the PR description), including that the
|
|
@claude review — addressed all four observations from the previous review (envelope now uses the negotiated version, input-round cap added with a covering test, forbidden-on-modern comment; abort-during-poll explained). Please take another look. |
|
Claude finished @cliffhall's task in 2m 1s —— View job Re-review: Tasks extension — review follow-upsRe-read the follow-up commit ( Verification1. Envelope now tracks the negotiated version ✅ — 2. Abort-during-poll ✅ (reasoning accepted) — walked the same paths in your reply: user cancel routes through 3. Input-round cap ✅ — the shared 4. One minor, non-blocking FYI (pre-existing, not introduced here)The poll loops call VerdictThe era-fork design remains clean, the follow-ups tightened the two real edges (version lockstep + unbounded re-prompt) without touching the working loop mechanics, and coverage grew with the changes. Looks good to merge. ✅
|
|
Thanks for the re-review and the merge 👍 On the FYI: agreed — the re-prompt-on- No further changes on this pass. |
Two bug fixes reported during manual testing of the tasks era-fork (#1631): 1. A modern task paused at `input_required` (e.g. `modern_loop_task`, which never advances) could not be cancelled: the poll loop blocked on the pending-request modal, so `cancelRequestorTask` sent `tasks/cancel` but the modal kept re-prompting. Now each modern poll loop registers a per-task AbortController (`registerTaskInputAbort`), `cancelRequestorTask` aborts it to reject the pending elicitation and unblock the poll, and the embedded input requests are tagged with their owning task id (`RELATED_TASK_META_KEY`) so the pending-request UI's Cancel action cancels the TASK rather than sending a "cancel" answer the server would re-prompt on. 2. On the legacy server, cancelling a task briefly showed CANCELLED then flipped to COMPLETED when the in-flight tool call resolved. Cancellation is a deliberate terminal decision, so `ManagedRequestorTasksState` now remembers cancelled task ids and ignores any later non-cancelled status update. Also: move the compact task id onto its own line in the embedded monitoring sidebar so the status badge / Cancel Task control don't wrap; DRY the duplicated task poll-interval logic into a shared `taskPollInterval` helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
|
@claude review New commit
Plus the embedded-sidebar TaskCard header fix and a |
|
Claude finished @cliffhall's task in 3m 46s —— View job Re-review: commit
|
Recapture the five tasks flow screenshots against the current build and add two demonstrating the post-review fixes: modern_loop_task cancelled from the pending-request modal (uncancelable-loop fix) and a legacy task staying CANCELLED after the in-flight call resolves (sticky-cancel fix). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
…ng test Re-review of the cancelable-loop / sticky-cancel fix raised two non-blocking hardening items: 1. The legacy tasks/list refresh() rebuilt the list from the server, honoring only dismissedTaskIds — so a cooperative-cancel server that re-lists a user-cancelled task as completed could un-stick the cancel on a manual Refresh. The refresh path now pins a cancelledTaskIds task to "cancelled" (keeping it visible-as-cancelled, matching the live-merge handlers) rather than dropping it. Covered by a new state test. 2. Added an App.test.tsx case locking in the user-facing half of the fix: Cancel on a task-input-required elicitation calls cancelRequestorTask (not respond). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
|
Thanks for the re-review — both observations were fair; addressed in 1. Sticky cancel bypassed by the legacy const page = result.tasks
.filter((t) => !this.dismissedTaskIds.has(t.taskId))
.map((t) =>
this.cancelledTaskIds.has(t.taskId)
? { ...t, status: "cancelled" as const }
: t,
);Dropping it would make a user-cancelled task vanish on Refresh, whereas the live-merge path ( 2. App-level cancel-routing untested — agreed, that's the user-facing half. Added an |
|
@claude review Addressed both non-blocking observations from the last re-review in
|
|
Claude finished @cliffhall's task in 57s —— View job Re-review: commit
|
|
Thanks — agreed on the cosmetic |
Closes #1631
Forks the Tasks tab by protocol era (SDK V2 + New Spec, card 8/10). The legacy 2025-11-25 core-tasks flow is preserved; a new
io.modelcontextprotocol/tasks(SEP-2663) implementation is added for modern (2026-07-28) connections and gated on the extension being negotiated.The SDK reality this works around
SDK v2 didn't just remove the tasks helpers — it actively blocks the extension on a modern connection in three places:
tasks/get/tasks/update/tasks/cancelare spec-method names absent from the 2026-07-28 era, soclient.request(...)throwsMethodNotSupportedByProtocolVersionbefore anything hits the wire.resultType: "complete" | "input_required"— aresultType: "task"CreateTaskResultis rejected outright, and the error carries no payload.createMcpHandler) era-gates inboundtasks/*too, so a conformant SDK-v2 server answers them-32601— the extension can't even be served through the SDK.So the Inspector implements the extension itself (as the issue anticipated), without patching the SDK:
tools/call(a real modern method). TheresultType: "task"response is rewritten at the transport into a benignCallToolResultcarrying the realDetailedTaskin_meta— aftertrackResponselogs the true frame, so the Protocol/Network tabs still showresultType: "task".pollTaskToolCallreads the handle from_metaand drives the poll.tasks/get/tasks/update/tasks/cancelgo over a raw-wire request channel that bypasses the era gate: it mints a string JSON-RPC id, stamps the full modern envelope (protocolVersion/clientInfo/clientCapabilities), sends straight through the transport (still logged), and is consumed by the transport before the SDK Client sees the response.input_requiredtasks reuse the existing pending-request modal viafulfilInputRequests, answered withtasks/update. Notasks/list, no blockingtasks/result— the completed task inlines its result.Changes
modernTaskSchemas.ts(explicit SEP-2663 wire schemas + normalize/handle helpers); era-forkedgetRequestorTask/cancelRequestorTask, newupdateRequestorTask, era-forkedpollTaskToolCall; the transport-rewrite + raw-wire channel (messageTrackingTransport.tsgains rewrite/consume hooks); advertise the tasks extension in client capabilities so every modern request declares it (enables server-directed creation).ManagedRequestorTasksState.refresh()is era-aware — legacy paginatestasks/list; modern re-polls the handles the client already holds (no server list).capabilities.tasks(legacy) OR the negotiated extension (modern).modernTasksprop.modern-tasks.ts— a shared poll-driven runtime +modern_task/modern_input_tasktools, served via an Express interceptor ahead of the SDK handler (the SDK can't). New configstasks-modern-http.json/tasks-legacy-http.json.Verification
inspectorClient-tasks-era.test.ts) drives both eras against real servers: create → poll → input_required →tasks/update→ inline result, unsolicited-handle passthrough, unknown-id error, modern store re-poll, and the legacytasks/listflow. Unit coverage formodernTaskSchemasand the raw-wire channel (transport-null, send-failure, timeout, error response, teardown).pr-screenshots/for the modern create/poll/inline-result, the moderninput_requiredelicitation →tasks/update, and the legacytasks/list/tasks/resultflow.npm run cigreen.Follow-ups (addressed in this PR)
input_requirednote. A modern task round now carries a distincttask-input-requiredpending-request origin, so the modal note reads "your answer is submitted via atasks/updaterequest (SEP-2663), not a retry" — instead of the MRTR "retry the original request" copy.tools/callis now detected (in the rewritten result's_meta) and polled to completion bycallTool, so the call resolves to the task's final result and the Tasks tab tracks it — matching the run-as-task path. The two poll loops share extracted helpers.Bug fixes (post-review,
7a8d791) — found in manual testinginput_requiredloop. A modern task paused atinput_requiredblocked its poll loop on the pending-request modal, socancelRequestorTasksenttasks/cancelbut the modal kept re-prompting (reproducible with the new never-completingmodern_loop_task). Each modern poll loop now registers a per-taskAbortController(registerTaskInputAbort);cancelRequestorTaskaborts it to reject the pending elicitation and unblock the poll, and the embedded input requests are tagged with their owning task id (RELATED_TASK_META_KEY) so the modal's Cancel cancels the task rather than sending a "cancel" answer the server would re-prompt on.CANCELLEDthen flipped toCOMPLETEDwhen the in-flighttools/callresolved.ManagedRequestorTasksStatenow remembers cancelled task ids and ignores any later non-cancelledstatus update, so a deliberate cancel wins.taskPollIntervalhelper.Note on SDK legacy
Confirmed there is no SDK tasks runtime to reuse: the only
-legacypackage is@modelcontextprotocol/server-legacy(frozen SSE transport + OAuth AS helpers, zero task exports), and noTaskStore/callToolStream/ task-handler registration exists anywhere in the SDK — only the deprecated wire schemas (kept "for interoperability only"), which we reuse for the legacy path. The tasks runtime was deleted, not relocated, and there's noext-taskspackage installed.Smoke test (web UI, remote proxy — proof of functionality)
Driven end-to-end against the real modern + legacy test servers, screenshots freshly recaptured after the review fixes.
Modern — connected (
MCP 2026-07-28), Tasks tab gated on the negotiated extension:Modern —
modern_taskrun as task:CreateTaskResult→tasks/getpoll → inline result (notasks/list/tasks/result):Modern —
modern_input_taskatinput_required: embedded elicitation surfaced with the accurate "submitted via atasks/updaterequest (SEP-2663), not a retry" note:Modern — after answering:
tasks/updatesubmitted, task completes with the input echoed:Modern — bug fix (
7a8d791):modern_input_tasknever-completing loop (modern_loop_task) is now cancelable — clicking the pending-request modal's Cancel closes the modal and settles the taskcancelled(previously it re-prompted forever):Legacy (2025-11-25, unchanged) —
capabilities.tasks+tasks/list/tasks/result. (The Logs tab also shows here because this server advertiseslogging; that tab is gated oncapabilities.loggingand is era-agnostic as of #1629 — modern servers supporting logging get it too, with the per-request opt-in control.)Legacy — bug fix (
7a8d791): cancelling a task via the Cancel Task link now stayscancelled— a late completion of the in-flight call no longer flips it back tocompleted(shown after a 6s wait):🤖 Generated with Claude Code
https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5