Skip to content

Support MCP Tasks for long-running analysis operations #97

Closed

Description

@morluto

Summary

Add a provider-neutral asynchronous job model and expose eligible long-running REA operations through capability-negotiated MCP Tasks. Preserve synchronous tool calls for clients that do not support Tasks.

MCP Tasks are experimental. REA's core execution model must not depend directly on unstable SDK APIs; the MCP Tasks adapter should sit over an internal operation abstraction with explicit ownership, status, cancellation, retention, and result identity.

Current state in REA 1.3.0

User problem

Expensive work can exceed a comfortable tool-call lifetime. Agents cannot:

  • start work and continue other reasoning;
  • recover a result after a client reconnect;
  • poll durable phase status;
  • cancel through a stateful protocol;
  • distinguish waiting for user input from active computation;
  • retrieve completed evidence without re-running analysis.

Proposed architecture

1. Internal operation model

Introduce an SDK-independent operation state machine with queued, working, input_required, completed, failed, and cancelled states.

Each operation should own:

  • cryptographically strong ID;
  • operation kind and normalized request identity;
  • originating session/authorization context;
  • created/updated timestamps;
  • bounded TTL;
  • status and safe status message;
  • progress state;
  • cancellation signal;
  • cleanup state;
  • final typed tool result or typed failure;
  • evidence IDs produced during execution.

2. MCP Tasks adapter

When the client advertises the required Tasks capability:

  • accept a task-augmented tools/call;
  • return CreateTaskResult promptly;
  • implement tasks/get, tasks/result, tasks/list, and tasks/cancel;
  • attach io.modelcontextprotocol/related-task metadata to associated progress and elicitation;
  • bind task access to the originating connection or authorization context;
  • make tasks/result return exactly the underlying tool result.

3. Compatibility path

For clients without Tasks:

4. Initial eligible operations

Start with operations whose runtime or output justifies task execution:

  1. binary/Hopper open and analysis;
  2. exhaustive artifact inventory;
  3. bounded process capture;
  4. persistent cross-version investigation;
  5. reconstruction verification;
  6. large batch decompilation or comparison.

Small navigation and read-only metadata calls should remain synchronous.

Security and lifecycle requirements

  • Task IDs must be unguessable and scoped to the originating context.
  • tasks/list must not expose work across clients.
  • Cancellation must stop owned work and run verified cleanup.
  • Expired results must be deleted promptly.
  • Task results must retain Evidence v2 identity and limitations.
  • input_required must not be used to bypass permission policy.
  • An MCP disconnect may retain a task only when its authorization context remains safely recoverable; otherwise cancel it.
  • Concurrency and retained-byte limits must be enforced per client.

Acceptance criteria

  • An internal operation abstraction exists independently of MCP SDK Tasks types.
  • Hopper analysis, artifact inventory, process capture, cross-version investigation, and reconstruction verification can run through it.
  • Capability-negotiated MCP Tasks support tasks/get, tasks/result, tasks/list, and tasks/cancel.
  • tasks/result is contract-equivalent to the corresponding synchronous tool result.
  • Status messages identify useful phases without exposing sensitive provider diagnostics.
  • Progress tokens continue across the task lifetime.
  • input_required can associate a permission elicitation from Use MCP elicitation for scoped process-capture session grants #96 with the task.
  • Cancellation propagates through providers and verifies cleanup.
  • Results have documented TTL, byte, and concurrency limits.
  • Task access is bound to the correct connection/authorization context.
  • Synchronous fallback remains fully supported.
  • Tests cover success, typed failure, cancellation, cancellation races, expiry, input_required, disconnect, result retrieval, unauthorized lookup, list isolation, and unsupported-client fallback.
  • Documentation marks the MCP Tasks surface experimental and identifies the supported protocol/SDK versions.

Non-goals

  • Making every tiny REA tool asynchronous.
  • Treating Tasks as permanent evidence storage.
  • Allowing task execution to expand filesystem, executable, or network policy.
  • Depending on deprecated MCP sampling, roots, or logging.

Dependencies

July 2026 SDK and Tasks extension update

REA currently pins the split MCP SDK packages at 2.0.0-beta.4. Investigation of beta.3 and beta.4 found that their exported task schemas describe the experimental 2025-11-25 task design, but the SDK does not provide the former high-level task manager/runtime. Meanwhile, current MCP Tasks work has moved to the Extensions Track and uses a different evolving contract, including different operation and result shapes.

The internal operation model in this issue remains required and should proceed independently of MCP wire types. The MCP adapter described above is now a historical target, not an implementation contract.

Before implementing the public adapter:

  • select and document one exact Tasks extension revision and compatible SDK version;
  • reconcile tasks/list and tasks/result assumptions with the selected extension;
  • reconcile task capability negotiation, result discrimination, update/input flow, cancellation, and related-task metadata with that revision;
  • keep all extension-specific schemas and lifecycle translation in the MCP adapter;
  • retain synchronous fallback and ordinary progress/cancellation from Emit meaningful MCP progress and propagate cancellation through owned analysis work #98;
  • add conformance tests proving the selected wire contract rather than relying only on exported TypeScript types.

Acceptance criteria referring to specific task methods or metadata should be evaluated against the selected extension revision before implementation. No task capability should be advertised until REA implements and tests the complete selected contract.

Activity

  1. morluto commented on Jul 17, 2026

    @morluto
    OwnerAuthor

    Current external-contract research confirms this should remain open but must not target the removed experimental SDK API. The MCP TypeScript SDK v2 removed its prior experimental Tasks surface pending the SEP-2663 Tasks Extension. REA should first select and pin an exact extension revision, then implement an SDK-independent retained-operation state machine and conformance adapter while preserving the synchronous path. Progress and resource prerequisites are already shipped.

  2. morluto commented on Jul 20, 2026

    @morluto
    OwnerAuthor

    Split into focused child issues:

    These replace the broad remaining scope in this issue. Closing this parent can happen once all children are closed.

  3. morluto commented on Jul 20, 2026

    @morluto
    OwnerAuthor

    Closing as out of scope / premature for the current local CLI/MCP reverse-engineering focus: no supporting code exists, and these areas should be revisited only after in-tree providers and the public boundary are stable.

  4. added
    enhancement
    area: mcp
    on Oct 12, 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

    area: mcpenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions