# get_task

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

The CodePanel MCP tool that returns one task with each run's model, status, outcome, tokens, cost, checks and pull request.

`get_task` returns one task as [`list_tasks`](/docs/mcp-server/list_tasks) shows it plus its `prompt`, with each of its runs: the model it ran on, how it ended, what it cost and the pull request it opened.

## When to call it

- **To see why a task ended as it did:** each run's `outcome`, `checksPassed`, `ownerInterrupts` and `unansweredQuestions`.
- **To follow a run's pull request:** take `prNumber` and the task's `repo` to [`get_review`](/docs/mcp-server/get_review). A run does not copy its review or merge; the review data is read where it lives.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `taskId` | string | yes | Id of a task, from list_tasks or start_task |
| `detail` | boolean | no | Add the prompt and every run field; compact without it |

It only reads: the server marks it `readOnlyHint: true`, so clients that ask before a write can run it without asking.

## What it returns

`task` and `runs`, oldest run first. The task says what started it:

| Field | Meaning |
| --- | --- |
| `origin` | `manual` (the app), `api`, `mcp`, `cli`, or `rule:<ruleId>` for an autopilot rule's task; `null` for a task queued before origins were recorded |
| `originClient` | The client as it named itself (`claude-code`, `codepanel-cli`), or `null` |
| `trigger` | A rule's task only: `ruleId`, `ruleName` (`null` once the rule is deleted), `trigger`, `why` (the event in words, such as `CI failed on main at a1b2c3d: test`), `url` (the run's log, the pull request or the issue), `eventKey` and `receivedAt`; `null` for every other task |

The surface comes from the `X-CodePanel-Surface` header the CLI and MCP server send; a call without it, or with any other value, is `api`. The header is the caller's own word, like `originClient`: it labels a task and grants nothing.

Each run has:

| Field | Meaning |
| --- | --- |
| `attempt` | 1 for the task's first run, then 2 and on |
| `provider`, `modelId`, `mode` | What it ran on, as it was when the run started, and the mode it ran in |
| `status` | `queued`, `starting`, `working`, `waiting`, `checking`, `reviewing`, `stopped`, `succeeded` or `failed` |
| `outcome` | `pr_opened`, `no_change`, `failed`, `stopped`, `budget_cap` or `timed_out`; `null` while the run goes on |
| `tokensIn`, `tokensOut`, `usd` | What it used and spent |
| `activeMs` | Sandbox time awake; against `endedAt - startedAt` it is the run's active share |
| `checksPassed` | Whether the environment's checks passed, or `null` until they ran |
| `ownerInterrupts` | Questions the policy sent to the owner |
| `unansweredQuestions` | Questions the agent put to the owner that no one answered; a first run with any is not a first-try pass in the agent's record. `null` on runs from before the count |
| `endReason`, `endNote` | Why a failed run needs you, and that in words with the next step: `needs_owner` or `stuck` from the runner, `runner_lost` when its runner stopped answering for over 90 minutes and CodePanel ended the run (retry the task to run it again), or `gateway_unreachable` when the run holds production read tools and its AI Gateway could not be reached, so CodePanel ended it rather than call the provider direct; `null` otherwise |
| `prNumber`, `startedAt`, `endedAt` | The pull request it opened, and when it ran |

A missing task, a malformed id and another account's task are all `Task not found`.

## The same step without MCP

| Surface | Form |
| --- | --- |
| HTTP API | `GET /tasks/get?taskId=…` with the `read` scope |
| Dashboard | Tasks → the task |

## What the server tells your agent

The description your agent reads when it lists the tools:

> Use it after start_task for the run id to pass to wait_for_run, or to see how each attempt at a task went. One task as list_tasks shows it, with runs, newest attempt last: each run's id, attempt, status, outcome (pr_opened|no_change|failed|stopped|budget_cap|timed_out, or null while it runs), modelId, usd, checksPassed (null until checks ran), prNumber, startedAt and endedAt. detail: true adds the task's prompt and each run's provider, mode, tokens, activeMs, ownerInterrupts, unansweredQuestions (questions for the owner no one answered; a run with any is no first-try pass) and timings. A pull request's review and merge are read with get_review by repo and prNumber.

## Related

- [`list_tasks`](/docs/mcp-server/list_tasks): every task and its id.
- [`get_review`](/docs/mcp-server/get_review): the review of a run's pull request.
- [MCP server](/docs/mcp-server): install, sign-in and every other tool.
