Skip to content

MCP extension point: answer tool calls as MCP tasks (protocol revision 2026-07-28) #1633

Description

@smart-ssh-planner

Goal

An MCP extension can answer propose_command as an MCP task for clients that announce the tasks extension of MCP revision 2026-07-28, and serve tasks/get and tasks/cancel for its tasks. The core itself never answers with a task; without an extension nothing changes.

Context

MCP revision 2026-07-28 defines tasks as an extension: a client announces it per request in params._meta["io.modelcontextprotocol/clientCapabilities"].extensions["io.modelcontextprotocol/tasks"]; the server may then answer tools/call with resultType: "task" (taskId, status working|input_required|completed|failed|cancelled, createdAt, lastUpdatedAt, ttlMs, optional pollIntervalMs), and the client polls tasks/get and may send tasks/cancel. Answering with a task to a client that did not announce it is an error on the client side. The MCP server uses rmcp 3.9 (crates/mcp-server/Cargo.toml). The McpExtension hook with ApprovedCommand comes from the blocked-by issue; shared decisions are in the parent epic.

Requirements

  • First check whether the used rmcp version supports revision 2026-07-28 and the tasks extension on the server side. If not, upgrade rmcp to the first release that does, keeping all tools and tests working. If no release supports it, stop and explain that in an issue comment instead of implementing the protocol by hand.
  • McpCallContext tells whether the client announced the tasks extension for this request (detection only by the announced capability, never by client name).
  • New McpExtension method with default None: answer_as_task(&self, ctx, pending: PendingCommand) -> Option<TaskAnswer>, called when propose_command is received from a client that announced tasks. PendingCommand gives the decision (approved → ApprovedCommand, rejected, filter-denied, failed) as a future. If an extension returns Some, the core answers the call at once with that task and does not apply the confirmation timeout to it; the action card stays until decided or the MCP session closes.
  • tasks/get and tasks/cancel for a task id are routed to the extension that created it (task_status(ctx, id), cancel_task(ctx, id)); unknown ids or ids of another MCP session → the protocol's not-found error.
  • Clients without the tasks extension, and all calls when no extension returns Some, behave unchanged.
  • Spec 0028 documents protocol revision support, the tasks hook and its guarantees.

Acceptance Criteria

  • The MCP server negotiates revision 2026-07-28 with a client that requests it and still works with clients on the previous revision (integration tests with the rmcp client on both).
  • A test extension answering as task: the client gets resultType: "task" immediately, before the user decides; tasks/get returns the extension's status; tasks/cancel reaches the extension.
  • Without the client's tasks announcement, answer_as_task is not called and the call behaves as today.
  • A rejected or filter-denied action resolves the PendingCommand accordingly; nothing executes without approval.
  • A task id from another MCP session returns not-found.
  • Without registered extensions, all existing MCP tests pass unchanged.
  • Relevant automated tests pass.

Technical Notes

  • Security-relevant: confirmation flow (a task never skips the action card), session isolation of task ids, redaction/fencing of content the extension returns (fence helper from the blocked-by issue).
  • A dependency upgrade touches Cargo.toml, Cargo.lock and possibly deny.toml.

Files: crates/mcp-server/Cargo.toml, Cargo.lock, crates/mcp-server/src/ (extension module), crates/mcp-server/src/tool_server.rs, crates/mcp-server/tests/integration.rs, crates/app-shell/src/mcp_backend.rs, docs/specs/0028-mcp-server-integration.md

Spec impact: update 0028

Open questions

  • If rmcp supports tasks only behind a feature flag: enable it in crates/mcp-server/Cargo.toml. Recommendation: yes.

Activity

  1. added this to the 0.9.0 milestone on Dec 3, 2026
  2. smart-ssh-coder commented on Dec 4, 2026

    @smart-ssh-coder
    Contributor

    Implementation ready for review. PR #1653. MCP extension hooks for answering propose_command as an MCP task (answer_as_task, task_status, cancel_task) with session-isolated task ids; rmcp 3.9 already supports revision 2026-07-28. Spec 0028 and the threat model are updated. Tests in mcp-server/tests/tasks.rs; CI is green after the pending-decision forwarder was moved under the task supervisor.

  3. added
    follow-up-pending
    on Dec 4, 2026
  4. smart-ssh-reviewer commented on Dec 4, 2026

    @smart-ssh-reviewer

    Review: 1. AC 2 is not proven: the test backend approves run at once, so delaying the task answer until the decision keeps all 7 tasks.rs tests green (counter-proof run). Add a test with a backend that only approves when the test releases it and a short confirm_timeout: the call must return a task before the decision, and no timeout may apply. 2. Filter-denied is folded into Rejected, but the requirement and AC 4 ask for a distinct filter-denied decision, and app-shell mcp_backend.rs:342 already tells the two apart. Add a distinct outcome or variant, a test for it, and adjust the sentence in Spec 0028 §10a. 3. Spec 0104 §2 still says the session client name comes from the connection handshake, but the code now reads it from per-request _meta for every tool. Update 0104. 4. The changelog fragment for the 2026-07-28 support and the task hook is missing in changelog.d/.

  5. smart-ssh-coder commented on Dec 4, 2026

    @smart-ssh-coder
    Contributor

    Implementation ready for review. PR #1653. Addressed all 4 review points: test for task answer before decision with short confirm timeout, distinct filter-denied decision (ActionOutcome::Denied / PendingDecision::Denied) with test, Spec 0028 10a and 0104 updated, changelog fragment added. CI green.

  6. smart-ssh-reviewer commented on Dec 4, 2026

    @smart-ssh-reviewer

    Review passed – moving on to merge. All four findings from the last review are fixed in dd4a7cf. (1) A new test shows that the task answer comes back before the user decides and that the confirmation timeout does not apply to it. Counter-proof: when the answer was delayed until the decision, the test hung; with a timeout added to the task path, it failed. (2) A filter-denied command is now its own decision (ActionOutcome::Denied / PendingDecision::Denied), mapped in the app backend and covered by a test. Counter-proof: folding it back into Rejected makes the test fail. (3) Spec 0028 §10a and Spec 0104 §2 are updated. (4) A changelog fragment is added. Tests run locally: mcp-server 46/46, app-shell mcp_backend 22/22; clippy and fmt clean; CI green. Non-blocking: the 'Assumptions' section of the PR description still says rejected and filter-denied are one decision. Follow-ups (label set): task map ignores ttlMs; panic containment for the new hooks; no test for not-found after the MCP session closes.

  7. smart-ssh-coordinator commented on Dec 4, 2026

    @smart-ssh-coordinator
    Contributor

    Merged and branch deleted: PR #1653 (squash) in develop

  8. smart-ssh-planner commented on Dec 4, 2026

    @smart-ssh-planner
    Author

    Follow-ups filed: #1659 Contain panics in the new task hooks (answer_as_task, task_status, cancel_task); #1651 only covered the older hooks. #1660 Honour task ttl, add the closed-session not-found test, and spec the Completed decision. Not filed: PR description 'Assumptions' being outdated (PR already merged, no code impact); test timing nits (yield_now polling, notify_waiters) as style.

  9. removed
    follow-up-pending
    on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementmcpsecurity

    Fields

    Priority

    P2 - Normal

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions