FileReadTool
Read text, images, PDFs, and notebooks from disk
FileEditTool
In-place string replacement inside an existing file
FileWriteTool
Create or fully overwrite a file
NotebookEditTool
Add, replace, or delete Jupyter notebook cells
FileReadTool
Reads a file from the local filesystem and returns its contents. Handles plain text, images (PNG, JPEG, GIF, WebP), PDFs, and Jupyter notebooks (.ipynb) transparently based on file extension.
Tool name: ReadRead-only: yes
Concurrency-safe: yes
Destructive: no
Parameters
Absolute path to the file to read. Tilde (
~) and relative segments are expanded automatically.Line number (1-indexed) to start reading from. Omit to read from the beginning. Only relevant for text files.
Maximum number of lines to return. Omit to read to the end of the file (subject to the per-session token limit).
Page range for PDF files, e.g.
"1-5", "3", or "10-20". Only applies to .pdf files. Maximum 20 pages per request. Pages are 1-indexed.Return value
The return type is a discriminated union keyed ontype:
type | Description |
|---|---|
text | Plain text with filePath, content, numLines, startLine, totalLines |
image | Base64-encoded image with base64, media type, originalSize, and optional dimensions |
notebook | Jupyter notebook with filePath and cells array |
pdf | Base64-encoded PDF with filePath, base64, and originalSize |
file_unchanged | Deduplication stub — file content is identical to a prior read still in context |
Lines are returned with
N: prefixes (e.g. 1: import React from 'react') to make line-number references unambiguous.Concurrency and staleness
FileReadTool stores a modification-time snapshot inreadFileState for every file it reads. FileEditTool and FileWriteTool check this snapshot before writing and refuse to proceed if the file has been modified since the last read.
Usage example
Blocked paths
For security, the tool refuses to read device files that produce infinite output or block on input:/dev/zero, /dev/random, /dev/urandom, /dev/stdin, /dev/tty, and their /proc/self/fd/ aliases.
FileEditTool
Performs an exact in-place string replacement inside an existing file. The model supplies the literal text to find (old_string) and the literal text to write in its place (new_string).
Tool name: EditRead-only: no
Concurrency-safe: no
Destructive: yes (modifies file in-place; a backup can be enabled via file history)
Parameters
Absolute path to the file to modify.
The exact text to search for and replace. Must match a unique substring of the file (use more context if the string appears more than once and
replace_all is false). Pass an empty string to write to an empty or non-existent file.The text to replace
old_string with. Must differ from old_string.When
true, all occurrences of old_string in the file are replaced. When false (default), the tool rejects the call if old_string appears more than once.Return value
On success the tool returns aFileEditOutput object:
Path to the file that was edited.
The actual string that was replaced (may differ slightly from
old_string due to quote-style normalization).The replacement text.
Unified-diff hunks describing the change.
true if the user manually edited the proposed change before approving it.Validation rules
The tool performs several checks before writing:old_stringandnew_stringmust differ.- The file must have been read in the current session (
FileReadToolupdates the cache). - The file must not have been modified since the last read (stale-write guard).
- When
replace_allisfalse,old_stringmust appear exactly once. .ipynbfiles must be edited with NotebookEditTool instead.
Usage example
FileWriteTool
Creates a new file or fully overwrites an existing file with the supplied content. Unlike FileEditTool, this is a whole-file operation — use it for new files or when a large portion of the file changes. Tool name:WriteRead-only: no
Concurrency-safe: no
Destructive: yes (existing content is replaced)
Parameters
Absolute path to the file to write. Parent directories are created automatically.
The full content to write to the file. The tool always uses LF (
\n) line endings regardless of the platform or previous file content.Return value
Either
"create" (new file) or "update" (existing file overwritten).Path to the file that was written.
The content that was written.
Diff hunks relative to the previous content (empty array for new files).
The previous file content before the write, or
null for new files.Staleness guard
Like FileEditTool, FileWriteTool refuses to overwrite a file that has changed on disk since it was last read. Read the file first if you need to overwrite an existing one.Usage example
NotebookEditTool
Edits cells inside a Jupyter notebook (.ipynb). Supports inserting new cells, replacing cell source, and deleting cells. FileEditTool will reject .ipynb files and redirect to this tool.
Tool name: NotebookEditRead-only: no
Concurrency-safe: no
Destructive: yes (modifies notebook in-place)
Parameters
Absolute path to the Jupyter notebook file.
The ID of the target cell. For
replace and delete modes, identifies the cell to operate on. For insert mode, the new cell is inserted after this cell (omit to insert at the beginning).The source code or markdown text for the cell.
Cell type:
"code" or "markdown". Required when edit_mode is "insert". Defaults to the existing cell’s type for replace.Operation to perform:
"replace"— update an existing cell’s source (default)"insert"— add a new cell aftercell_id"delete"— remove the cell identified bycell_id