# fs_read

Read a file on the machine, exactly as stored: text as text, anything else as base64. Up to 256 KiB per call by default (max_bytes up to 4 MiB); `truncated` says there is more, read on with offset. Paths holding keys and credentials (~/.ssh, ~/.aws, cmdop's own folder and the like) are refused.

**In short:** Risk class [`read`](https://docs.cmdop.ai/reference/tools.md#risk-classes). Over MCP call `fs_read`; over HTTP send `"tool": "fs_read"` 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 |
| --- | --- | --- | --- |
| `max_bytes` | `integer` | no | Read at most this many bytes (default 262144, at most 4194304). |
| `offset` | `integer` | no | Start at this byte (default 0). |
| `path` | `string` | yes | File on the machine. Absolute, or relative to the user's home folder; `~` is the home. |

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `data` | `string` | yes |  |
| `encoding` | `"utf8" | "base64"` | yes | `utf8` when `data` is the text itself, `base64` when the bytes are not valid UTF-8. |
| `offset` | `integer` | yes |  |
| `path` | `string` | yes | The file, resolved to an absolute path. |
| `size` | `integer` | yes | The file's whole size in bytes. |
| `truncated` | `boolean` | yes | The file goes on after what was returned; read again with a larger offset. |

## Examples

**MCP**

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

**HTTP**

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

## Limits

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