patch
Apply a unified diff to a file after verifying context lines, preserving original encoding and line endings. Use dry-run to preview changes.
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.
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 | |
| file_path | No | File to patch. Relative paths use the configured workspace or MCP client root |