Skip to main content

File Tools

Tools for reading, editing, and searching files on the host machine.

read_fileโ€‹

Read the contents of a file.

ParameterTypeDescription
file_pathstringAbsolute or relative file path
offsetintStarting line offset (default: 0)
limitintNumber of lines to read (default: 200)

Classification: Host (path-checked against restricted paths)

Return shape:

{
"status": "success",
"stdout": "file contents with line numbers",
"stderr": "",
"exit_code": 0,
"duration_ms": 15
}

edit_fileโ€‹

Apply an edit to a file using search-and-replace.

ParameterTypeDescription
file_pathstringFile path to edit
old_stringstringText to find (must be unique in file)
new_stringstringReplacement text
replace_allboolReplace all occurrences (default: false)

Classification: Host (path-checked against restricted paths)

Return shape:

{
"status": "success",
"stdout": "Edit applied successfully",
"stderr": "",
"exit_code": 0,
"duration_ms": 20
}

Notes:

  • The old_string must match exactly one location in the file (unless replace_all is true)
  • If the text appears multiple times and replace_all is false, the edit fails with an error describing the ambiguity

find_filesโ€‹

Search for files matching a pattern.

ParameterTypeDescription
patternstringGlob pattern (e.g., **/*.py, src/**/*.ts)
search_textstringText to search for within matched files (optional)
pathstringDirectory to search in (default: working directory)
max_resultsintMaximum number of results to return (default: 50)

Classification: Host (path-checked)

Return shape:

{
"status": "success",
"stdout": "list of matching file paths",
"stderr": "",
"exit_code": 0,
"duration_ms": 150
}

Related: Core Tools ยท Docker Sandbox