# check_plan

> Release: 0.13.0 · Last changed: 2026-11-30 · Source: https://github.com/KeiaiLab/SwarmOps/blob/stable/docs/reference/mcp-tools/check-plan.md

Says which of the checks of the tree that landing head onto target, main by default, would make a change needs: each is run or not\_applicable with its one reason, from the paths the change would change (as land\_check plans it, with base and idempotency\_key as land takes them) against each check's inputs. A plan fails closed: a conflict, more than 1,000 changed paths or a path it cannot read makes every check run, and widened\_by says why. Reads only: nothing runs a check. A check file that does not read is E\_CHECK\_FILE with its line and key.

```yaml
title: "check_plan"
description: "Plan which checks a change needs."
since: "0.1.0"
mutates: false
identity_required: false
cli_command: "swarmops check plan"
envelope_op: "check_plan"
request_type: "CheckPlanReq"
annotations: {"destructiveHint":false,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":true}
max_result_chars: null
```

## Input schema

`arguments` is a `CheckPlanReq`: `swarmops schema CheckPlanReq` prints the type. A field the type does not know is ignored.

| Field | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `base` | string or null | no |  | Where the change starts, as a land's `base`. When omitted, the merge base of `head` and the target's head, along first parents. |
| `checks` | array of string | no |  | Only these checks, each of the stage; empty (the default): every check. A name given twice counts once. |
| `head` | string | yes |  | The change's head. A revision as the caller wrote it, for the store to resolve: a ref name (`main`, `release/1.2`), a full 64-hex changeset id or a unique prefix of at least 12 hex digits, or a ref's earlier value: `<ref>@{N}` the value it held N moves before its current one (`@{0}` is the current value), `<ref>@{at=<unix seconds>}` the value set by its newest move recorded at or before that instant (the writer's clock, moves read in journal order); optionally followed by `~N` for the N-th first-parent ancestor. |
| `idempotency_key` | string or null | no |  | The change's land key, as a land's: a change the target holds a land of is `replayed`, and needs no check. |
| `stage` | string or null | no |  | Only the checks of this stage; every check when omitted. |
| `target` | string | no | `"main"` | The ref the change would land on: `main` or `release/<name>`, which must exist. |

### JSON Schema

As `tools/list` gives it: each `$ref` replaced by its definition, so that it stands alone.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "`check_plan` (CLI `check plan HEAD`): which of the checks of the tree that landing `head`\nonto `target` would make a change needs, and why. It plans as `land_check` plans one change\n(a head or base not found, a base that is no ancestor or a merge in the chain fails it, as it\nfails there). It takes no lock, writes nothing and runs nothing.",
  "properties": {
    "base": {
      "anyOf": [
        {
          "description": "A revision as the caller wrote it, for the store to resolve: a ref name (`main`,\n`release/1.2`), a full 64-hex changeset id or a unique prefix of at least 12 hex digits, or a\nref's earlier value: `<ref>@{N}` the value it held N moves before its current one (`@{0}`\nis the current value), `<ref>@{at=<unix seconds>}` the value set by its newest move\nrecorded at or before that instant (the writer's clock, moves read in journal order);\noptionally followed by `~N` for the N-th first-parent ancestor.",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Where the change starts, as a land's `base`. When omitted, the merge base of `head` and\nthe target's head, along first parents."
    },
    "checks": {
      "description": "Only these checks, each of the stage; empty (the default): every check. A name given\ntwice counts once.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "head": {
      "description": "The change's head. A revision as the caller wrote it, for the store to resolve: a ref name (`main`,\n`release/1.2`), a full 64-hex changeset id or a unique prefix of at least 12 hex digits, or a\nref's earlier value: `<ref>@{N}` the value it held N moves before its current one (`@{0}`\nis the current value), `<ref>@{at=<unix seconds>}` the value set by its newest move\nrecorded at or before that instant (the writer's clock, moves read in journal order);\noptionally followed by `~N` for the N-th first-parent ancestor.",
      "type": "string"
    },
    "idempotency_key": {
      "description": "The change's land key, as a land's: a change the target holds a land of is `replayed`,\nand needs no check.",
      "type": [
        "string",
        "null"
      ]
    },
    "stage": {
      "anyOf": [
        {
          "description": "When a check's answer is wanted. A check names one or more; `check run` runs one stage's\nchecks.",
          "oneOf": [
            {
              "const": "before-land",
              "description": "Before a change lands: the gate. The default.",
              "type": "string"
            },
            {
              "const": "after-land",
              "description": "After a change has landed.",
              "type": "string"
            },
            {
              "const": "scheduled",
              "description": "On a schedule.",
              "type": "string"
            },
            {
              "const": "release",
              "description": "Before a release is cut.",
              "type": "string"
            },
            {
              "const": "manual",
              "description": "Only when someone asks for it.",
              "type": "string"
            },
            {
              "const": "deploy",
              "description": "Before a deployment.",
              "type": "string"
            }
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "Only the checks of this stage; every check when omitted."
    },
    "target": {
      "default": "main",
      "description": "The ref the change would land on: `main` or `release/<name>`, which must exist.",
      "type": "string"
    }
  },
  "required": [
    "head"
  ],
  "title": "CheckPlanReq",
  "type": "object"
}
```

## Annotations

It only reads the store.

| Annotation | Value | Meaning |
| --- | --- | --- |
| `destructiveHint` | `false` | True: a tool that changes the store may overwrite or delete what is there, not only add to it. |
| `idempotentHint` | `true` | True: calling it again with the same arguments changes nothing more. |
| `openWorldHint` | `false` | True: it reaches beyond a closed set of things. Every tool here stays inside the store. |
| `readOnlyHint` | `true` | True: the tool does not change its environment, the store. |

Its entry in `tools/list` carries no `_meta`.

## CLI command

[`swarmops check plan`](../commands/check-plan.md) runs the same operation and prints the same envelope.

## Examples

### MCP

```json
{
  "id": 50,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "head": "[grouped]"
    },
    "name": "check_plan"
  }
}
```

```json
{
  "id": 50,
  "jsonrpc": "2.0",
  "result": {
    "content": [
      {
        "text": "{\"api\":1,\"meta\":{\"auth\":\"trust\",\"elapsed_ms\":\"[elapsed_ms]\",\"repo\":\"[tmp]/store\",\"resolved\":{\"[grouped]\":\"[grouped]\",\"main\":\"[grouped]\"}},\"ok\":true,\"op\":\"check_plan\",\"result\":{\"changed\":0,\"checks\":[],\"head\":\"[grouped]\",\"onto\":\"[grouped]\",\"outcome\":\"nothing_to_land\",\"target\":\"main\",\"tree\":\"[id20]\",\"vouched\":false}}",
        "type": "text"
      }
    ],
    "isError": false,
    "structuredContent": {
      "api": 1,
      "meta": {
        "auth": "trust",
        "elapsed_ms": "[elapsed_ms]",
        "repo": "[tmp]/store",
        "resolved": {
          "[grouped]": "[grouped]",
          "main": "[grouped]"
        }
      },
      "ok": true,
      "op": "check_plan",
      "result": {
        "changed": 0,
        "checks": [],
        "head": "[grouped]",
        "onto": "[grouped]",
        "outcome": "nothing_to_land",
        "target": "main",
        "tree": "[id20]",
        "vouched": false
      }
    }
  }
}
```

The server ran as `swarmops mcp --repo [tmp]/store --as agent/worker-17`, after `initialize`. Recorded by the MCP tests. A name in square brackets, such as `[tmp]` or `[c1]`, stands for what differs from run to run: the test's temporary directory, an id, a time, the version.

## Details

It plans landing `head` onto `target` (`main` by default) in the store the server was started on, by
the call `land_check` makes, with `base` and `idempotency_key` as `land` takes them: there is no
workspace or directory form here, which `swarmops check plan` serves on the command line. An
answer from the store says `vouched: false` and names the tree the landing would make, the
target's head it was made on and what the landing would come to.
With `stage`, it plans only the checks of that stage and echoes it; with `checks`, only those.
Each check is `run` or `not_applicable` with one reason, and a plan that cannot tell what changed
makes every check `run` and says why in `widened_by`.
Nothing runs the checks it plans, and nothing is written.

## Return information

A tool result: the envelope, whose `op` is `check_plan`, as `structuredContent` and again as the text of its one `content` block. `isError` is true exactly when the envelope's `ok` is false. On success the envelope's `result` is what [`swarmops check plan`](../commands/check-plan.md#return-information) returns.

## Errors

A failed call is a tool result with `isError: true`; the envelope's `error.code` is one of the [error codes](../errors.md).

- [`E_INVALID_ARG`](../errors.md#e_invalid_arg): arguments that do not fit `CheckPlanReq`, a field named twice among them included, or that break one of the server's own rules.
- [`E_NOT_A_REPO`](../errors.md#e_not_a_repo): the server's store is not there; the server serves on.
- [`E_INTERNAL`](../errors.md#e_internal): the operation panicked, a bug.

Then the errors of the operation, as [`swarmops check plan`](../commands/check-plan.md#errors) lists them.

## See also

- [`swarmops check plan`](../commands/check-plan.md)
- [MCP tools](README.md)
- [MCP integration](../../develop/mcp.md)
- [Error codes](../errors.md)
