read_file
Read the contents of a file.Input Parameters
Path to the file to read. Can be absolute or relative to workspace.
Response
Returns the complete file contents as a string.The file contents
Usage Example
Error Conditions
path is required- Missing path parameterfailed to read file- File does not exist or permission deniedaccess denied: path is outside the workspace- Path traversal attempt when workspace restriction is enabledaccess denied: symlink resolves outside workspace- Symlink escape attempt blocked
write_file
Write content to a file. Creates parent directories automatically if they don’t exist.Input Parameters
Path to the file to write. Parent directories will be created automatically.
Content to write to the file
Response
Returns a silent result (not shown to user, only logged for LLM).Confirmation message:
File written: {path}Usage Example
Error Conditions
path is required- Missing path parametercontent is required- Missing content parameterfailed to create directory- Cannot create parent directoriesfailed to write file- Permission denied or disk fullaccess denied: path is outside the workspace- Path traversal blocked
list_dir
List files and directories in a path.Input Parameters
Path to list. Defaults to current directory if not specified.
Response
Returns a formatted list of directory entries.Multi-line string with format:
DIR: {name}for directoriesFILE: {name}for files
Usage Example
Error Conditions
failed to read directory- Directory does not exist or permission deniedaccess denied: path is outside the workspace- Path traversal blocked
Security Features
Workspace Restriction
Whenrestrict=true is enabled during tool initialization:
- All paths are validated to be within the workspace directory
- Symlinks are resolved and checked to prevent escape attacks
- Path traversal patterns (
../) are blocked - Both absolute and relative paths are normalized and validated
Example Attack Prevention
Implementation Details
File permissions:- Directories created with
0755permissions - Files written with
0644permissions
- Relative paths are resolved against workspace directory
- Absolute paths are validated if workspace restriction is enabled
- Symlinks are followed and validated recursively