Skip to content
Edit this page View source of this page

MCP Tasks (SEP-2663)

fast-agent supports the modern MCP Tasks extension (io.modelcontextprotocol/tasks, protocol revision 2026-07-28) for long-running tool calls that may detach into the background or request interactive input (input_required).

How it works

  1. Foreground polling: When tools/call returns resultType: "task", fast-agent polls tasks/get at the server's advised pollIntervalMs. Polling alone is compliant with SEP-2663 (2026-07-28); no push subscription is needed.
  2. Automatic detach and idle wake (interactive TUI only): On a persistent MCP connection, tasks that finish within mcp.client.task_foreground_timeout_seconds (default 30.0) return their validated CallToolResult directly. Slower tasks detach and return a local handle such as task-1 without exposing the server's bearer taskId to the model. Background polling continues and queues an <mcp-task> update when the task reaches a terminal state or needs input. With wake enabled, that update starts a turn at the idle prompt. PTC (exec_sandbox), ACP, and non-interactive MCP tool calls wait for a terminal outcome rather than detaching on the timeout.
  3. Interactive input_required: Foreground tool calls, tasks(action="wait"), /tasks wait, and /tasks input fulfill elicitation/create and sampling/createMessage requests through the normal callbacks, then send tasks/update. Time spent handling input does not count against the foreground wait budget. Background polling can detect that input is needed, but never opens prompts or approval links itself.

Configuration

mcp:
  client:
    task_foreground_timeout_seconds: 30.0

Model tool (tasks)

When any attached server advertises io.modelcontextprotocol/tasks (or tracked tasks exist), the built-in tasks tool is exposed:

  • tasks(action="list")
  • tasks(action="status", task_id="task-1")
  • tasks(action="wait", task_id="task-1", wait_sec=30)
  • tasks(action="cancel", task_id="task-1")
  • tasks(action="wake", task_id="task-1", wake=true|false)

Inside PTC (exec_sandbox), await tasks(...) is also available.

Slash commands (/tasks)

Available in both the TUI and ACP:

  • /tasks or /tasks list — list active and recent MCP tasks
  • /tasks status <handle> — refresh and show detailed status/result
  • /tasks wait <handle> [seconds] — wait in the foreground (fulfills input_required if needed)
  • /tasks input <handle> — fulfill outstanding input_required prompts in the foreground
  • /tasks cancel <handle> — cooperatively cancel a task
  • /tasks wake <handle> [on|off] — toggle automatic idle-prompt wakeups
  • /tasks clear — clear finished tasks from local history

Session persistence

In-flight tasks (and terminal tasks with unconsumed wake updates) are saved in session snapshots and resumed on --resume with their original opaque handles. Forked sessions clear mcp_tasks so forks never contend over live server task IDs.

Try it live (mcp-tasks.fast-agent.ai)

  1. Open the MCP Tasks playground to create a room. Copy its MCP URL and connect from a terminal. Set task_foreground_timeout_seconds to 2.0 in fastagent.config.yaml (see above) so the example job detaches before it finishes.
fast-agent -x --url 'https://mcp-tasks.fast-agent.ai/r/<room>/mcp'

Ask for direct MCP tool calls, not calls through exec_sandbox, to exercise detachment.

  1. Detach and wake. Ask the agent to call run_job with name="nightly-eval", mode="task", steps=12, and step_ms=1500, then return to the prompt without waiting. Run /tasks to find the detached handle. With wake on, completion starts a new turn from the idle prompt.
  2. Handle input. Ask the agent to call deploy_release with service="checkout-api", environment="prod", and approval_mode="url" (or "form"). If the task detaches and reaches input_required, use /tasks input task-<n> to handle the request in the foreground. For URL approval, open the link shown to you or use Open approval page in the dashboard. This is a demo: never enter real credentials.
  3. Drive and cancel tasks. Ask the agent to call open_manual_task with title="operator-gate". In the dashboard, use Emit progress, Request form, or Complete, then check /tasks status task-<n> in the terminal. Start another task and run /tasks cancel task-<n> while it is working. Cancellation is cooperative; use /tasks status to check whether the server confirmed it.
  4. Resume. Leave a detached manual task running, exit the TUI, and rerun the command above with --resume latest (or --resume <session-id>). Use the same room URL and resume before the task expires. /tasks shows the original handle; finish the task from the dashboard to see the wake after reconnecting.

MCP Tasks playground dashboard and operator controls

Terminal showing the /tasks list and /tasks status detail