Skip to main content

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 (use memory_* 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 Parameters
string
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)
Output
string
File content with line numbers formatted as line_num│ content
integer
Total number of lines in the file
integer
Number of lines returned in this response
string
Absolute path to the file that was read
Example
Response
Constraints
  • Maximum file size: 1MB
  • For files larger than 1MB, use offset and limit parameters 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.
Not for workspace memory files like HEARTBEAT.md, MEMORY.md, etc. Use memory_write for those.
Input Parameters
string
required
Path to the file to write
string
required
Content to write to the file
Output
string
Absolute path to the file that was written
integer
Number of bytes written
boolean
Always true on successful write
Example
Response
Constraints
  • 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/ or context/ directories are rejected
  • Parent directories created automatically
  • Rate limited: 20 calls per minute, 200 per hour
Error Conditions
  • InvalidParameters: Content exceeds 5MB or path is a workspace file
  • ExecutionFailed: 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 Parameters
string
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
Output
string
Absolute path to the directory that was listed
array
Array of entry strings. Directories end with /, files show size in parentheses
integer
Number of entries returned
boolean
True if results were truncated (max 500 entries)
Example
Response
Constraints
  • 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 exact old_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.
Input Parameters
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.
Output
string
Absolute path to the file that was edited
integer
Number of replacements made
boolean
Always true on successful patch
Example
Response
Error Conditions
  • ExecutionFailed: old_string not found in file (check exact match including whitespace)
  • ExecutionFailed: Failed to read or write file
Constraints
  • Must read file before editing
  • Rate limited: 20 calls per minute, 200 per hour
  • Requires approval unless auto-approved