# fs_search

Find files under a folder by name pattern (`*`, `?`) and/or by plain text inside them; returns paths, and with content the first matching line. Bounded: depth 12 by default, 200 matches by default, 20 s at most; symlinks are not followed; folders holding keys and credentials are skipped. Hidden names only with hidden=true.

**In short:** Risk class [`read`](https://docs.cmdop.ai/reference/tools.md#risk-classes). Over MCP call `fs_search`; over HTTP send `"tool": "fs_search"` 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 |
| --- | --- | --- | --- |
| `content` | `string` | no | Text to find inside files (plain text, not a regular expression). Files over 4 MiB and files that are not text are skipped. Default: match by name only. |
| `hidden` | `boolean` | no | Also enter and match names starting with a dot. Default: `false`. |
| `ignore_case` | `boolean` | no | Compare `name` and `content` ignoring letter case. Default: `false`. |
| `limit` | `integer` | no | At most this many matches (default 200, at most 2000). |
| `max_depth` | `integer` | no | Folder levels below `root` to enter (default 12, at most 64). |
| `name` | `string` | no | File name pattern with `*` and `?`, matched against the name only, for example `*.rs`. Default: every name. |
| `root` | `string` | yes | Folder to search under. Absolute, or relative to the user's home folder. |

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `matches` | `object[]` | yes |  |
| `root` | `string` | yes | The root, resolved to an absolute path. |
| `scanned` | `integer` | yes | Files looked at. |
| `truncated` | `boolean` | yes | Stopped early: the limit, the time cap (20 s) or the file count cap was reached. |

## Examples

**MCP**

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

**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_search","args":{"root":"<root>"}}'
```

## 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).
