# disk_clean

Frees what disk_usage counts as cleanable: old caches deleted, old sessions moved to the Trash. Settings and credentials stay. dry_run lists first.

**In short:** Risk class [`destructive`](https://docs.cmdop.ai/reference/tools.md#risk-classes). Over MCP call `disk_clean`; over HTTP send `"tool": "disk_clean"` to [`POST /api/v1/call`](https://docs.cmdop.ai/reference/http/post-call.md).

## Arguments

Over MCP every tool also takes `machine`: the machine's name or id, optional when only one machine is online.

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `dry_run` | `boolean` | no | Say what would be removed and remove nothing. Default: `false`. |
| `older_than_days` | `integer` | no | Remove only files unchanged for at least this many days. It can only raise an item's own age. |
| `targets` | `string[]` | no | As in `disk_usage`: `agent:<id>` or `cache:<id>`. Absent: every one known. |

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `dry_run` | `boolean` | yes |  |
| `freed_bytes` | `integer` | yes | Bytes removed, or that would be on a dry run. |
| `targets` | `object[]` | yes |  |
| `truncated` | `boolean` | yes | The walk stopped at its limit: run it again to go further. |

## Examples

**MCP**

```json
{
  "name": "disk_clean",
  "arguments": {
    "machine": "<machine>"
  }
}
```

**HTTP**

```bash
curl -sS -X POST "https://<contour>.cmdop.dev/api/v1/call" \
  -H "Authorization: Bearer $CMDOP_TOKEN" \
  -H "x-cmdop: 1" \
  -H "Content-Type: application/json" \
  -d '{"machine":"<machine>","tool":"disk_clean","args":{}}'
```

## Limits

The call times out after 120 s (`timed_out`). Available since version 0.1.13. A refused or failed call returns one of the [error codes](https://docs.cmdop.ai/reference/errors.md).
