Patch
patchApply a single-file unified diff to an existing UTF-8 text file all-or-nothing: if any hunk mismatches its context, nothing is written. Use when you already hold a unified diff.
Instructions
Apply a single-file unified diff to one existing UTF-8 text file. Use when you hold a unified diff. Do not use it for one exact snippet; use edit instead. For pattern matches use replace_text; for new files, create. All or nothing: if any hunk mismatches its context, nothing is written; INVALID_INPUT usually names it. Header line numbers may be off. A diff of context lines only writes nothing and records no undo. File lines x diff lines over 10,000,000 fails with TOO_LARGE. Returns path, linesAdded, linesRemoved, size, lineCount, mimeType, kind, modified, resourceUri when linkable, and an undo id for undo (30 minutes) or undoUnavailable; dryRun adds the resulting diff.
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>",
"diff": "<diff>"
},
"name": "patch"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| diff | Yes | Single-file unified diff, at least one @@ hunk, hunks in file order. Multi-file diffs are rejected; a leading BOM is ignored. | |
| path | Yes | Existing text file to patch. Overrides the ---/+++ names in diff. | |
| dryRun | No | Check every hunk and return the resulting diff; write nothing. Counts come from the recomputed diff unless it times out. |