Overview
The file operations tools provide controlled access to the filesystem with path validation, sandboxing, and size limits. These tools operate on the local filesystem, not workspace memory (usememory_* tools for workspace operations).
Tools
read_file
Read a file from the local filesystem. Returns file content as text with support for partial reads. Input Parametersstring
required
Path to the file to read
integer
Line number to start reading from (1-indexed, optional)
integer
Maximum number of lines to read (optional)
string
File content with line numbers formatted as
line_num│ contentinteger
Total number of lines in the file
integer
Number of lines returned in this response
string
Absolute path to the file that was read
- Maximum file size: 1MB
- For files larger than 1MB, use
offsetandlimitparameters for partial reads - Requires approval unless auto-approved
- Runs in container domain
write_file
Write content to a file on the local filesystem. Creates the file if it doesn’t exist, overwrites if it does. Parent directories are created automatically. Input Parametersstring
required
Path to the file to write
string
required
Content to write to the file
string
Absolute path to the file that was written
integer
Number of bytes written
boolean
Always true on successful write
- Maximum content size: 5MB
- Workspace files (HEARTBEAT.md, MEMORY.md, IDENTITY.md, SOUL.md, AGENTS.md, USER.md, README.md) are rejected
- Files in
daily/orcontext/directories are rejected - Parent directories created automatically
- Rate limited: 20 calls per minute, 200 per hour
InvalidParameters: Content exceeds 5MB or path is a workspace fileExecutionFailed: Failed to create directories or write file
list_dir
List contents of a directory on the local filesystem. Shows files and subdirectories with their sizes. Input Parametersstring
default:"."
Path to the directory to list (defaults to current directory)
boolean
default:false
If true, list contents recursively
integer
default:3
Maximum depth for recursive listing
string
Absolute path to the directory that was listed
array
Array of entry strings. Directories end with
/, files show size in parenthesesinteger
Number of entries returned
boolean
True if results were truncated (max 500 entries)
- Maximum 500 entries returned
- Common directories excluded during recursion:
node_modules,target,.git,__pycache__,venv,.venv - Entries sorted with directories first, then alphabetically
apply_patch
Apply targeted edits to a file using search/replace. Finds the exactold_string and replaces it with new_string. Use for surgical code changes without rewriting entire files.
The
old_string must match exactly, including whitespace and indentation.string
required
Path to the file to edit
string
required
The exact string to find and replace
string
required
The string to replace it with
boolean
default:false
If true, replace all occurrences. If false, replaces first occurrence only.
string
Absolute path to the file that was edited
integer
Number of replacements made
boolean
Always true on successful patch
ExecutionFailed:old_stringnot found in file (check exact match including whitespace)ExecutionFailed: Failed to read or write file
- Must read file before editing
- Rate limited: 20 calls per minute, 200 per hour
- Requires approval unless auto-approved