# cancel_task

URL: https://codepanel.ai/docs/mcp-server/cancel_task

The CodePanel MCP tool that stops a task that has not ended and returns it before and after; its runs keep their records.

`cancel_task` stops a task that has not ended. Its status becomes `stopped`; a run still going on it ends as `stopped` with outcome `stopped`, and earlier runs keep their records. It needs the `tasks:write` scope.

## When to call it

- **To take back a task queued by mistake:** it undoes [`start_task`](/docs/mcp-server/start_task).
- **To stop work that is no longer wanted:** a `queued`, `running` or `needs_you` task.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `taskId` | string | yes | Id of a task, from list_tasks or start_task |

It writes: the server marks it `readOnlyHint: false` and `destructiveHint: true` (it can change what is already there), so a client that asks before writes asks here.

A task that has already ended (`succeeded`, `failed` or `stopped`) is refused.

## What it returns

`{ before, after }`, each as [`list_tasks`](/docs/mcp-server/list_tasks) shows the task. A cancelled task is not started again; queue a new one with `start_task`.

## The same step without MCP

| Surface | Form |
| --- | --- |
| HTTP API | `POST /tasks/cancel` with the `tasks:write` scope |
| Dashboard | The task's page → Cancel task |

## What the server tells your agent

The description your agent reads when it lists the tools:

> Use it to drop a task for good; to stop only the current attempt and keep the task, use stop_run. Stops a task that has not ended (queued, running or needs_you); its status becomes stopped and its runs keep their records. An ended task is refused. Needs the tasks:write scope. Returns { before, after }, each as list_tasks shows the task with detail.

## Related

- [`get_task`](/docs/mcp-server/get_task): the task and its runs.
- [MCP server](/docs/mcp-server): install, sign-in and every other tool.
