patch
Apply a unified diff to a file with context-line verification, preserving encoding and per-line endings. Preview changes with a dry run before writing.
Instructions
Applies a unified diff patch to a file. Parses @@ hunk headers, verifies context lines, and applies changes. Encoding-aware: preserves original file encoding. Line-ending aware: each line keeps its own ending (a mixed CRLF/LF file is not rewritten) and a file without a trailing newline does not gain one. Use dry_run=true to preview without modifying the file.
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": {
"patch": "<patch>"
},
"name": "patch"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Alias for file_path | |
| patch | Yes | Unified diff text (output of the diff tool) | |
| dry_run | No | Preview patch result without modifying the file: true or false. Default: false | |
| encoding | No | Charset override, e.g. CP949; overrides .editorconfig, BOM takes priority | |
| file_path | No | File to patch. Relative paths use the configured workspace or MCP client root | |
| expected_hash | No | Expected raw-file SHA-256; mismatch rejects the patch |