Long-running tasks
How an assistant follows work that outlives one MCP call, such as a deployment, a restore or a shell command.
On this page
Work that takes longer than one request, such as creating a site, restoring a backup or running a command, answers with a task. The assistant polls the task until it ends, then reads the result.
The API follows the same work as operations: see Long-running work.
Follow a task
Start the work
Call the tool. It answers a task id and a status of
working.{ "taskId": "cfmcpt_a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6", "status": "working", "statusMessage": "Snapshot queued", "pollIntervalMs": 5000 }Poll the task
Read the task every 5 seconds with
tasks/get. A client without tasks support callscorestack_task_getinstead.{ "name": "corestack_task_get", "arguments": { "task_id": "cfmcpt_a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6" } }Read the result
When the status is
completed, the answer carries the tool's final result. Work that ended badly iscompletedtoo: its result is a refusal such aswork_failedorcommand_failed, so checkisError.
Rules
| Rule | Value |
|---|---|
| Statuses | working, then completed, cancelled or failed |
| Poll interval | 5 seconds |
| Result kept after the task ends | 24 hours |
| Who can read or cancel a task | The grant that started it, while it still holds the scopes and pins that call needed |
| Cancel | tasks/cancel or corestack_task_cancel |
A cancel stops work the Control Panel can stop. A change that cannot be stopped keeps running, and its status says so.
Commands
corestack_exec_command waits before it answers a task, so a short command returns its output in one call.
| Argument | Default | Maximum |
|---|---|---|
wait_seconds: how long the call waits | 30 | 60 |
timeout_seconds: how long the command may run | 3,600 | 86,400 |
Read a running command's output with corestack_command_output_get and stop it with corestack_command_cancel.
A grant that is revoked or expires stops its commands: see Revoke access.