file_read
Read files or specific line ranges, head/tail sections, or regex matches to avoid loading whole files. Output is line-numbered and truncated to save tokens.
Instructions
Read a file, or just the part you need: a line range (start_line/end_line, negatives count from the end), head_lines/tail_lines, or match="regex" to return only matching lines with optional context — far cheaper than reading a whole file. Output is line-numbered and middle-truncated at max_output_bytes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path, absolute or relative to the server cwd. | |
| match | No | Regex: return only lines that match (grep mode). | |
| context | No | Lines of context around each match. Default 0. | |
| encoding | No | base64 to read binary bytes. | |
| end_line | No | 1-based last line, inclusive. Negative counts back from the end. | |
| max_bytes | No | Byte cap on returned output before middle-truncation. Lower it to save tokens. | |
| force_text | No | Read as UTF-8 even if the file looks binary. | |
| head_lines | No | Just the first N lines. | |
| start_line | No | 1-based first line. Negative counts back from the end. | |
| tail_lines | No | Just the last N lines. | |
| ignore_case | No | Shorthand for match_flags="i". | |
| match_flags | No | Regex flags for match, e.g. "i". | |
| max_matches | No | Cap on matches in grep mode. Default 200. | |
| line_numbers | No | Prefix lines with numbers. Default true. |