file_replace_lines
Replace an inclusive 1-based line range with new content, preview changes with a dry run, and keep each edit undoable while preserving file formatting.
Instructions
Replace an inclusive 1-based line range and return operation_id and undo_available.
Use this for genuinely positional work; file_replace_text is cheaper when
the line numbers are not already known. Out-of-range references are
refused, never clamped. The file's newline convention and byte-order mark
are preserved, and a replacement without a trailing newline does not fuse
lines. dry_run returns a unified diff preview and writes nothing.
Otherwise the operation is recorded and undoable.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>",
"start_line": "<start_line>",
"end_line": "<end_line>",
"replacement": "<replacement>"
},
"name": "file_replace_lines"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| dry_run | No | ||
| end_line | Yes | ||
| start_line | Yes | ||
| replacement | Yes | ||
| expected_hash | No | ||
| expected_content | No |