# repair

> Release: 0.11.0 · Last changed: 2026-10-24 · Source: https://github.com/KeiaiLab/SwarmOps/blob/stable/docs/reference/mcp-tools/repair.md

Rebuilds what the journal can rebuild (its offsets, the index, the ref files), quarantines damaged objects and drops damaged cache entries, then verifies; the journal itself is never cut. dry\_run lists the actions only.

```yaml
title: "repair"
description: "Repair the store."
since: "0.4.0"
mutates: true
identity_required: false
cli_command: "swarmops repair"
envelope_op: "repair"
request_type: "RepairReq"
annotations: {"destructiveHint":true,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":false}
max_result_chars: null
```

## Input schema

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

| Field | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `dry_run` | boolean | no | `false` | List what it would do, each with `done: false`, and write nothing. |

### 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": "`repair`: rebuild what the journal can rebuild (`journal.off`, the index, the ref files),\nquarantine damaged objects and drop damaged cache entries. It never cuts the journal.",
  "properties": {
    "dry_run": {
      "default": false,
      "description": "List what it would do, each with `done: false`, and write nothing.",
      "type": "boolean"
    }
  },
  "title": "RepairReq",
  "type": "object"
}
```

## Annotations

It removes or rewrites store files that the journal and the objects stand for, and moves no ref and records nothing. Run again, it finds its work done.

| Annotation | Value | Meaning |
| --- | --- | --- |
| `destructiveHint` | `true` | 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` | `false` | True: the tool does not change its environment, the store. |

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

## CLI command

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

## Examples

### MCP

No recorded example yet.

## Return information

A tool result: the envelope, whose `op` is `repair`, 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 repair`](../commands/repair.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 `RepairReq`, 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 repair`](../commands/repair.md#errors) lists them.

## See also

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