files/update
Edit an existing file in place by appending text or replacing a line range. Use absolute path, specify start/end lines or append flag.
Instructions
Edits part of an EXISTING file in place: appends text or replaces an inclusive line range. Mutating and not atomic; the file keeps its mode and owner. To write a whole file use files/create; to see the lines first use files/read with start_line/end_line. With append: true exactly content is added at the end (no newline is added, include your own) and the file is created if missing, though not its parent directories; append wins over any line range. Otherwise start_line AND end_line are both required (1-indexed, end_line >= start_line), the file must exist, and those lines are replaced by content (one trailing newline of content is ignored; an end_line past the end is clamped; a start_line past the end adds content as a new last line). There is no insert or delete mode: replacing with empty content leaves one empty line. Returns Successfully appended to PATH or Successfully updated lines A-B in PATH, no diff. path must be absolute; privileged: true (a grant, and for root a paths: entry) edits files you cannot write.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path of the file to edit | |
| append | No | If true, append content at the end (creates the file if missing); takes precedence over start_line/end_line | |
| content | Yes | Text to append, or to replace the line range with (no newline is added when appending) | |
| end_line | No | Last line to replace (inclusive, >= start_line; past the end of the file is clamped) | |
| privileged | No | Run as root. Needs a grant for this tool in mcp-sudo.yaml and a `paths:` entry covering the path, otherwise refused | |
| start_line | No | First line to replace (1-indexed); required together with end_line unless append is true |