read_file - Read File
Overview
The read_file tool reads the content of a specified file from the local filesystem. It handles text files, images (PNG, JPG, GIF, WEBP, SVG, BMP), and PDF files. For text files, it can read specific line ranges.
Tool Name
- Internal Name:
read_file - Display Name: ReadFile
- Icon: FileSearch
Parameters
Required Parameters
| Parameter | Type | Description |
|---|---|---|
absolute_path | string | The absolute path to the file to read (e.g., /home/user/project/file.txt). Relative paths are not supported. You must provide an absolute path. |
Optional Parameters
| Parameter | Type | Description |
|---|---|---|
offset | number | For text files, the 0-based line number to start reading from. Requires limit to be set. Use for paginating through large files. |
limit | number | For text files, maximum number of lines to read. Use with offset to paginate through large files. If omitted, reads the entire file (if feasible, up to a default limit). |
prefer_full_read | boolean | Set to true to bypass large-file preview guards. Only use if you are confident the file is small enough to read fully. |
Features
File Type Support:
- Text files: Supports various text encodings
- Image files: PNG, JPG, GIF, WEBP, SVG, BMP
- PDF files: Can extract PDF content
Pagination:
- Use
offsetandlimitparameters to paginate through large text files - Suitable for handling very large files without loading everything at once
- Use
Security Restrictions:
- File path must be absolute
- File must be within the project root directory
- Respects
.siiignorefile patterns
Large File Protection:
- Default preview limits for large files
- Can bypass limits with
prefer_full_readparameter
Usage Examples
Read Entire File
json
{
"absolute_path": "/home/user/project/src/main.ts"
}Paginated Read (lines 10-20)
json
{
"absolute_path": "/home/user/project/logs/app.log",
"offset": 10,
"limit": 10
}Force Full Read
json
{
"absolute_path": "/home/user/project/config.json",
"prefer_full_read": true
}Return Value
The tool returns an object containing:
llmContent: The actual file content (text or other format)returnDisplay: User-friendly display informationsummary: Operation summary (optional)
Error Handling
Possible error scenarios:
Path Errors:
- Path is not absolute
- Path is outside project root directory
- File is ignored by
.siiignore
File Access Errors:
- File does not exist
- No read permission
- Path is a directory, not a file
Parameter Errors:
offsetis negativelimitis less than or equal to 0- Incorrect parameter types
Notes
- Path Requirement: Must use absolute paths, relative paths are not supported
- Performance: For large files, use pagination
- Security: Tool checks if file is within allowed directory scope
- Encoding: Text files default to UTF-8 encoding
Related Tools
write_file: Write to filereplace: Replace text in fileread_many_files: Read multiple files in batchlist_directory: List directory contents
