# get_plan

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

The CodePanel MCP tool that returns one saved plan in full: its steps, history and the nextAction that says which step to work on, even inside a sub-plan.

`get_plan` returns one saved plan in full: every step with its status, acceptance criteria and evidence, the latest history, and a `nextAction` that names the step to work on now. Call it to pick up where you or another agent stopped. It needs only the `read` scope, and it works only where the deployment has plan tracking turned on.

## When to call it

- **Right after `list_plans`,** to open the plan you chose.
- **At the start of a session** that continues a plan, before you change anything.
- **After a push or a long gap,** when you are not sure what the plan says now. Every write tool already returns the plan, so you don't need `get_plan` after your own write.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `planId` | string | yes | Plan id, from list_plans or create_plan |

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

`planId` comes from [`list_plans`](/docs/mcp-server/list_plans) or [`create_plan`](/docs/mcp-server/create_plan). An unknown id, and a plan that belongs to another account, both fail the same way:

```text
CodePanel: Tracked plan not found
```

With plan tracking off on the deployment, the call fails with `CodePanel: Plan tracking is off on this deployment (PLAN_TRACKING)`.

## What it returns

The summary fields `list_plans` gives (`planId`, `title`, `status`, `repo`, `parentPlanId`, `parentStep`, `progress`, `updatedAt`), plus:

- `goal` and `createdAt`.
- `steps`, in plan order. Each has `ref` (like `S3`), `title`, `detail`, `acceptance`, `status` (`pending`, `in_progress`, `done`, `blocked` or `skipped`), `reason`, `evidence`, `subplans`, `updatedAt` and `completedAt`. `subplans` lists the `planId`, `title` and `status` of each sub-plan that expands the step. Call `get_plan` on those ids to read them.
- `history`: the latest 50 changes, newest first. Each has `kind`, the `step` it touched, `from` and `to`, `reason`, `detail`, `agent` and `at`. A `deviation` entry records a step that was started or finished out of order, with the reason you gave.
- `nextAction`.

### `nextAction`

`nextAction` is the one thing to do next, in the same five fields every time:

| `action` | Means | Fields set |
| --- | --- | --- |
| `start` | The first open step is `pending`: start it | `step` |
| `continue` | A step is `in_progress`: keep going | `step` |
| `unblock` | The first open step is `blocked`: resolve it, or start a later step and give a reason | `steps`, every blocked step |
| `add_steps` | The plan has no steps yet | none |
| `done` | The plan is `completed` or `abandoned`, or no step is left to do | none |

`planId` always names the plan the action belongs to, and `reason` says why. `step` is `null` and `steps` is `[]` when they don't apply.

When the step in progress has an active sub-plan, `nextAction` descends into it, up to the nesting limit of 5 plans. Its `planId` is then the sub-plan's, and its `reason` starts with the parent step and the sub-plan's title. Act on the `planId` it gives, not the one you asked for.

## Examples

These responses come from a test account on a local backend, trimmed to the first history entry and the first step.

```json title="Call"
{"planId": "xd7ffsskhwq6bg3ff59ptazsh98j7xjs"}
```

```json title="Result (trimmed)"
{
  "createdAt": 1794614635238,
  "goal": "Make the login limit apply per client, not per X-Forwarded-For value",
  "history": [
    {
      "agent": "claude-code",
      "at": 1794614643860,
      "detail": null,
      "from": "in_progress",
      "id": "x57b6e0bt4sdk6k3m57pyeezah8j6hce",
      "kind": "step_status",
      "reason": null,
      "step": "S1",
      "to": "done"
    }
  ],
  "nextAction": {
    "action": "start",
    "planId": "xd7ffsskhwq6bg3ff59ptazsh98j7xjs",
    "reason": "it is the next pending step",
    "step": "S3",
    "steps": []
  },
  "parentPlanId": null,
  "parentStep": null,
  "planId": "xd7ffsskhwq6bg3ff59ptazsh98j7xjs",
  "progress": {
    "blocked": 0,
    "done": 1,
    "inProgress": 0,
    "pending": 2,
    "skipped": 0,
    "total": 3
  },
  "repo": "codepanel-dev/web-app",
  "status": "active",
  "steps": [
    {
      "acceptance": "A test sends ten requests with different X-Forwarded-For values and the eleventh is refused",
      "completedAt": 1794614643860,
      "detail": "src/server/auth/rateLimit.ts:48",
      "evidence": "rateLimit.test.ts: 10 spoofed requests, 11th refused (commit 3f2a9c1)",
      "reason": null,
      "ref": "S1",
      "status": "done",
      "subplans": [],
      "title": "Key the limiter on the trusted hop",
      "updatedAt": 1794614643860
    }
  ],
  "title": "Fix rate limiter bucket key",
  "updatedAt": 1794614643860
}
```

`S1` is `done` with its `evidence`, so `nextAction` moves to the next step in plan order. That is `S3`, which was inserted after `S1` and so comes before `S2`. The full result lists all three steps and four history entries.

## The same step without MCP

| Surface | Form |
| --- | --- |
| CLI | `codepanel plan <planId> [--json]` prints the steps and the next action ([CLI](/docs/cli#tracked-plans)) |
| HTTP API | [`GET /plans/get`](/docs/api#get-plansget) with `planId` |
| Dashboard | The **Plans** page shows the same steps, `nextAction` and history |

## What the server tells your agent

The description your agent reads when it lists the tools:

> One saved plan in full, to pick up where you or another agent left off. Returns the plan: planId, status (active, completed, abandoned), progress, steps (ref like S3, status pending|in_progress|done|blocked|skipped, acceptance, evidence, reason, subplans), history (newest first, with deviations and reasons) and nextAction. Act on nextAction: start or continue its step (in its planId, which may be a sub-plan), unblock its steps, add_steps, or done.

## Related

- [`list_plans`](/docs/mcp-server/list_plans): find the `planId`.
- [`update_plan_step`](/docs/mcp-server/update_plan_step): act on `nextAction`.
- [`create_plan`](/docs/mcp-server/create_plan): how sub-plans are made.
- [Keep a long plan across sessions](/docs/mcp-server#keep-a-long-plan-across-sessions): the workflow.
- [Tracked plans](/docs/api#tracked-plans): the rules, in the HTTP API reference.
