util_patch_apply
Apply a unified diff — Apply a unified diff (git diff / diff -u output) to a file's text and get the patched text back, like GNU patch. text= original file content (empty for a new file), patch= the diff. Hunks are located by context with line-offset search and fuzz (fuzz=0-3, default 2, drops outer context lines); already-applied hunks are detected; CRLF and missing-final-newline markers are preserved. Optional: reverse=true (un-apply), ignore_whitespace=true, atomic=true (422 and no result if any hunk fails), file= (pick one file from a multi-file patch). Returns status applied|partial|failed|already_applied, result text, per-hunk report (line, offset, fuzz), lines added/removed and the rejected hunks. Offline. Price: $0.002 USDC (Base, via x402).
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": {
"text": "<text>",
"patch": "<patch>"
},
"name": "util_patch_apply"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | alpha beta gamma | |
| patch | Yes | @@ -1,3 +1,3 @@ alpha -beta +BETA gamma |