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.
| Capability | workspace.apply_patch |
|---|---|
| Area | Workspace and files |
| Access | changes files |
| Reaches | — |
| Rights | write |
| Dry run | dry_run, on unless the call turns it off |
Arguments
| Argument | Type | Description |
|---|---|---|
patchrequired | string | A 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_run | boolean | Only 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.
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" ] } }}