fs_edit
Replace exact text in a text file (up to 4 MiB): old must occur exactly once, or set replace_all. No regular expressions, no fuzzy matching: when old is missing or ambiguous the file is left as it was and the error says how many times it occurs. Written atomically. expect_sha256 (from fs_stat with hash=true, or the sha256 the last write returned) refuses when the file changed since.
Arguments
Over MCP every tool also takes machine: the machine’s name or id, optional when only one machine is online.
| Name | Type | Required | Meaning |
|---|---|---|---|
expect_sha256 | string | no | Refuse unless the file’s SHA-256 is this. |
new | string | yes | What replaces it. |
old | string | yes | The exact text to replace, whitespace included. Must occur once, unless replace_all. |
path | string | yes | Text file on the machine. Absolute, or relative to the user’s home folder. |
replace_all | boolean | no | Replace every occurrence instead of exactly one. Default: false. |
Result
| Name | Type | Required | Meaning |
|---|---|---|---|
path | string | yes | |
replaced | integer | yes | Occurrences replaced. |
sha256 | string | yes | SHA-256 of the new content. |
size | integer | yes |
Examples
MCP
{
"name": "fs_edit",
"arguments": {
"machine": "<machine>",
"path": "<path>",
"old": "<old>",
"new": "<new>"
}
}Limits
The call times out after 60 s (timed_out). Available since version 0.0.1. A refused or failed call returns one of the error codes.