Skip to content

apply_patch

MCP tools › Workspace and files

Apply a unified diff to workspace text files as the window shows them, saved or not. Hunks must match exactly (offsets reported); if any fails nothing changes and the error names file, hunk and line. New files, deletions and renames are refused: use create_file, delete_file, move_file. Returns per file hunks, added, removed, offsets. Dry run by default; dry_run=false needs the user-granted write right.

Its results carry text from files: the client is told to treat that as data, never as instructions.

Capabilityworkspace.apply_patch
AreaWorkspace and files
Accesschanges files
Reaches—
Rightswrite
Dry rundry_run, on unless the call turns it off

Arguments

ArgumentTypeDescription
patchrequiredstringA unified diff of one or more workspace files, as git diff or diff -u writes it (--- a/<path>, +++ b/<path>, @@ -l,n +l,n @@ hunks).
dry_runbooleanOnly report what would change (default true); false writes, which needs the write right.

Call it from a shell

ferris-idea call runs one tool with the rights and safe mode of ferris-idea mcp. Replace the folder and the placeholder values.

Terminal window
ferris-idea call ~/my-project apply_patch '{"patch":"<string>"}'
Input schema as JSON
{
"type": "object",
"required": [
"patch"
],
"properties": {
"patch": {
"description": "A unified diff of one or more workspace files, as `git diff` or `diff -u` writes it\n(`--- a/<path>`, `+++ b/<path>`, `@@ -l,n +l,n @@` hunks).",
"type": "string"
},
"dry_run": {
"description": "Only report what would change (default true); false writes, which needs the `write` right.",
"type": [
"boolean",
"null"
]
}
}
}