patch_file
Replace a specific string or code block in a file without rewriting the whole file. Uses a unique match and creates an automatic backup before applying the change.
Instructions
Replace a specific string or block of code within a file without rewriting the whole file. The old_string must appear exactly once in the file. A backup is created automatically before the change is applied.
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": {
"filepath": "<filepath>",
"old_string": "<old_string>",
"new_string": "<new_string>"
},
"name": "patch_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filepath | Yes | Path to the file, relative to project root or absolute | |
| new_string | Yes | The string to replace it with | |
| old_string | Yes | The exact string to find and replace. Must be unique in the file — include extra surrounding lines if needed to make it unique. |