Skip to content

code_actions

MCP tools › Code insight and refactoring

Quick fixes and refactorings the file's language server offers at a position or selection: title, kind, preferred and the problems each fixes. Only applicable actions are listed unless applicable_only false, which appends the rest with the reason in disabled (apply_code_action refuses those). refactoring finds only that refactoring as its shortcut does: the places it can act on, or the editor's message when there is none. In Python, Ferris IDEA's own Extract variable/method/constant and Inline variable work without a language server. In Java, inline on a method lists the IntelliJ-style variants (all usages, keep or remove the method, this usage only). Apply with apply_code_action.

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

Capabilitycode.code_actions
AreaCode insight and refactoring
Accessreads only
Reachesprocess
Rightsnone
Dry rundry_run, on unless the call turns it off

Arguments

ArgumentTypeDescription
pathrequiredstringWorkspace-relative file path.
start_linerequiredinteger0-based start line.minimum 0
start_characterrequiredinteger0-based start character (Unicode scalar values).minimum 0
end_lineinteger0-based end line (default: start line).minimum 0
end_characterinteger0-based end character (default: start character).minimum 0
titlestringTitle of the action to apply (apply_code_action only).
refactoringstringOnly this refactoring, as its shortcut finds it (code_actions only): extract_variable, extract_constant, extract_field, extract_method, introduce_parameter, inline or any. Returns the places (range, text, matching actions); a bare caret is widened to the expressions around it (SPEC-0095 v2).
dry_runbooleanOnly report the edits (default true; apply_code_action only).
applicable_onlybooleanLeave out the actions the server offers as disabled, i.e. that cannot be applied at this place (default true; code_actions only). With false they follow the applicable ones, each with the reason in disabled.

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 code_actions '{"path":"<string>","start_line":1,"start_character":1}'
Input schema as JSON
{
"type": "object",
"required": [
"path",
"start_line",
"start_character"
],
"properties": {
"path": {
"description": "Workspace-relative file path.",
"type": "string"
},
"start_line": {
"description": "0-based start line.",
"type": "integer",
"minimum": 0
},
"start_character": {
"description": "0-based start character (Unicode scalar values).",
"type": "integer",
"minimum": 0
},
"end_line": {
"description": "0-based end line (default: start line).",
"type": [
"integer",
"null"
],
"minimum": 0
},
"end_character": {
"description": "0-based end character (default: start character).",
"type": [
"integer",
"null"
],
"minimum": 0
},
"title": {
"description": "Title of the action to apply (`apply_code_action` only).",
"type": [
"string",
"null"
]
},
"refactoring": {
"description": "Only this refactoring, as its shortcut finds it (`code_actions` only): `extract_variable`,\n`extract_constant`, `extract_field`, `extract_method`, `introduce_parameter`, `inline` or `any`. Returns the places (range, text,\nmatching actions); a bare caret is widened to the expressions around it (SPEC-0095 v2).",
"type": [
"string",
"null"
]
},
"dry_run": {
"description": "Only report the edits (default true; `apply_code_action` only).",
"type": [
"boolean",
"null"
]
},
"applicable_only": {
"description": "Leave out the actions the server offers as disabled, i.e. that cannot be applied at this\nplace (default true; `code_actions` only). With false they follow the applicable ones,\neach with the reason in `disabled`.",
"type": [
"boolean",
"null"
]
}
}
}