Provides basic file operations for Amplifier agents.
- Python 3.11+
- UV - Fast Python package manager
# macOS/Linux/WSL
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"Enables agents to read and write files within configured safe paths.
Module Type: Tool
Mount Point: tools
Entry Point: amplifier_module_tool_filesystem:mount
The module is split into three specialized tools, each in its own file following the modular design philosophy:
read.py- ReadTool for reading files with line numbering and paginationwrite.py- WriteTool for writing/overwriting filesedit.py- EditTool for exact string replacements
Read the contents of a file with cat-n style line numbering and pagination support.
Input:
file_path(string, required): Absolute path to the file to readoffset(integer, optional): Line number to start reading from (1-indexed). Use for large files.limit(integer, optional): Number of lines to read. Defaults to 2000. Use for large files.
Output:
- File contents formatted with line numbers (cat -n style)
- Lines longer than 2000 characters are truncated
- Total line count and lines read
- Warning if file is empty
Example:
1→# This is line 1
2→# This is line 2
3→# This is line 3
Write content to a file (overwrites if exists).
Input:
file_path(string, required): Absolute path to the file to writecontent(string, required): Content to write to the file
Output:
- Success with bytes written
- Creates parent directories automatically if needed
Note: You should read the file first before overwriting to avoid data loss.
Perform exact string replacements in files.
Input:
file_path(string, required): Absolute path to the file to modifyold_string(string, required): The exact text to replacenew_string(string, required): The text to replace it with (must be different)replace_all(boolean, optional): Replace all occurrences. Defaults to false. If false and multiple occurrences exist, operation fails.
Output:
- Success with number of replacements made and bytes written
- Fails if old_string not found or not unique (unless replace_all=true)
Note: Read the file first to see the exact text including indentation. When copying from read_file output, exclude the line number prefix (everything before and including the tab character).
[[tools]]
module = "tool-filesystem"
config = {
# Read operations (permissive by default)
allowed_read_paths = null, # null = allow all reads (default), or ["path1", "path2"]
# Write/Edit operations (restrictive by default)
allowed_write_paths = ["."], # Default: current directory and subdirectories only
require_approval = false
}Philosophy: Reads are low-risk (consuming data), writes are high-risk (modifying system state).
Read operations (read_file):
- Permissive by default (
allowed_read_paths = nullallows all reads) - Enables reading context files from package installations
- Can be restricted with
allowed_read_paths = ["dir1", "dir2"]
Write operations (write_file, edit_file):
- Restrictive by default (
allowed_write_paths = ["."]) - Current directory and all subdirectories allowed
- Prevents unintended modifications outside project
Path validation:
- All paths resolved before checking
- Subdirectory traversal supported (parent path check)
- Path traversal attacks prevented
amplifier-core>=1.0.0
Note
This project is not currently accepting external contributions, but we're actively working toward opening this up. We value community input and look forward to collaborating in the future. For now, feel free to fork and experiment!
Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit Contributor License Agreements.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.