Skip to content

surround_with

MCP tools › Code insight and refactoring

Surround With for Java: wraps whole statement lines start_line..end_line (1-based, inclusive) of a workspace .java file in kind (if, if_else, while, do_while, for, try_catch, try_finally, try_catch_finally, synchronized, runnable, braces), indenting them one step. A local variable declared in the lines and used after them is declared before the construct and assigned inside. dry_run defaults to true and returns the new text; dry_run=false writes the file (needs the write right) and refuses if it changed meanwhile.

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

Capabilitycode.surround_with
AreaCode insight and refactoring
Accesschanges files
Reaches—
Rightswrite
Dry rundry_run, on unless the call turns it off

Arguments

ArgumentTypeDescription
pathrequiredstringWorkspace-relative .java file.
start_linerequiredintegerFirst 1-based line to wrap.minimum 0
end_linerequiredintegerLast 1-based line to wrap (inclusive).minimum 0
kindrequiredstringif, if_else, while, do_while, for, try_catch, try_finally, try_catch_finally, synchronized, runnable or braces.
dry_runbooleanOnly return the new text (default true); false writes the file.

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 surround_with '{"path":"<string>","start_line":1,"end_line":1,"kind":"<string>"}'
Input schema as JSON
{
"type": "object",
"required": [
"path",
"start_line",
"end_line",
"kind"
],
"properties": {
"path": {
"description": "Workspace-relative `.java` file.",
"type": "string"
},
"start_line": {
"description": "First 1-based line to wrap.",
"type": "integer",
"minimum": 0
},
"end_line": {
"description": "Last 1-based line to wrap (inclusive).",
"type": "integer",
"minimum": 0
},
"kind": {
"description": "`if`, `if_else`, `while`, `do_while`, `for`, `try_catch`, `try_finally`,\n`try_catch_finally`, `synchronized`, `runnable` or `braces`.",
"type": "string"
},
"dry_run": {
"description": "Only return the new text (default true); false writes the file.",
"type": [
"boolean",
"null"
]
}
}
}