# fs_stat

Facts about one file or folder without reading it: kind, size, change and creation time, permission bits, whether it is writable, a symlink's target; with hash=true also its SHA-256, for a later fs_write or fs_edit with expect_sha256. Paths holding keys and credentials are refused.

**In short:** Risk class [`read`](https://docs.cmdop.ai/reference/tools.md#risk-classes). Over MCP call `fs_stat`; over HTTP send `"tool": "fs_stat"` 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 |
| --- | --- | --- | --- |
| `hash` | `boolean` | no | Also return the file's SHA-256 (files up to 64 MiB). Pass it as `expect_sha256` to fs_write or fs_edit to refuse a write when the file changed in between. Default: `false`. |
| `path` | `string` | yes | File or folder on the machine. Absolute, or relative to the user's home folder. |

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `created` | `integer` | no | Unix seconds, where the file system keeps it. |
| `kind` | `"file" | "dir" | "symlink" | "other"` | yes |  |
| `link_target` | `string` | no | When `path` itself is a symlink: where it points. |
| `mode` | `string` | no | Permission bits in octal, for example `644`. |
| `modified` | `integer` | no | Unix seconds. |
| `path` | `string` | yes | Resolved absolute path (symlinks followed). |
| `sha256` | `string` | no | Lower-case hex, when `hash` was asked and the path is a file of at most 64 MiB. |
| `size` | `integer` | yes | Bytes; 0 for folders. |
| `writable` | `boolean` | yes | Whether the user the machine program runs as may write it. |

## Examples

**MCP**

```json
{
  "name": "fs_stat",
  "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_stat","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).
