editor_action
MCP tools › Window and UI driver
Preview an editor action (see action) on a workspace file at the given carets, as the editor does it. Returns the resulting text and 1-based carets; the file is not written and the clipboard is not touched (copy actions return copied). Some actions add fields: changed_lines, folds, context, choices, font_size. copy_reference gives the qualified symbol name from the language server, else path and line. unwrap where nothing can be unwrapped and auto_indent_lines in a language without braces are errors.
Its results carry text from files: the client is told to treat that as data, never as instructions.
| Capability | ui.editor_action |
|---|---|
| Area | Window and UI driver |
| Access | reads only |
| Reaches | process |
| Rights | none |
| Dry run | none |
Arguments
| Argument | Type | Description |
|---|---|---|
pathrequired | string | Workspace-relative file. |
actionrequired | string | duplicate, delete_lines, move_lines_up, move_lines_down, join_lines,
toggle_comment, indent, outdent, newline, type, backspace, matching_bracket,
move_element_left, move_element_right, expand_word, expand_word_backward,
sort_lines, reverse_lines, transpose, add_carets_to_line_ends,
indents_to_spaces, indents_to_tabs, copy_absolute_path, copy_file_name,
copy_content_root_path, copy_source_root_path, copy_path_with_line,
copy_reference, cut_to_line_end, auto_indent_lines, context_info, fold_block,
fold_selection, collapse_all, expand_all, collapse_recursively,
expand_recursively, expand_all_to_level, expand_to_level, collapse_doc_comments,
expand_doc_comments, increase_font_size, decrease_font_size, complete_statement, unwrap. |
level | integer | For expand_all_to_level and expand_to_level: the level, 1–5; for unwrap: which block,
1 = the innermost (default 1).minimum 0 |
overwrite | boolean | For type: overwrite mode — the text replaces as many characters after each caret as it
has itself, up to the line end, and may be longer than one character (default false). |
first_visible_line | integer | For context_info: the first line in view, 1-based (default 1).minimum 0 |
shown_line | integer | For context_info: the line a previous call returned, to go on outwards from it.minimum 0 |
tab_size | integer | Columns a tab advances to, for indents_to_spaces and indents_to_tabs, 1–32
(default 4).minimum 0 |
count | integer | How often expand_word or expand_word_backward is used in a row, 1–100 (default 1).minimum 0 |
caretsrequired | array of object | Carets and selections. |
carets[].linerequired | integer | Line of the caret (selection end).minimum 0 |
carets[].columnrequired | integer | Column of the caret.minimum 0 |
carets[].anchor_line | integer | Line where the selection starts (default: no selection).minimum 0 |
carets[].anchor_column | integer | Column where the selection starts.minimum 0 |
text | string | Character to type for type. |
indent | string | Indentation step (default four spaces). |
comment_token | string | Line comment token (default from the file's language). |
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 editor_action '{"path":"<string>","action":"<string>","carets":[]}'Input schema as JSON
{ "properties": { "path": { "description": "Workspace-relative file.", "type": "string" }, "action": { "description": "`duplicate`, `delete_lines`, `move_lines_up`, `move_lines_down`, `join_lines`,\n`toggle_comment`, `indent`, `outdent`, `newline`, `type`, `backspace`, `matching_bracket`,\n`move_element_left`, `move_element_right`, `expand_word`, `expand_word_backward`,\n`sort_lines`, `reverse_lines`, `transpose`, `add_carets_to_line_ends`,\n`indents_to_spaces`, `indents_to_tabs`, `copy_absolute_path`, `copy_file_name`,\n`copy_content_root_path`, `copy_source_root_path`, `copy_path_with_line`,\n`copy_reference`, `cut_to_line_end`, `auto_indent_lines`, `context_info`, `fold_block`,\n`fold_selection`, `collapse_all`, `expand_all`, `collapse_recursively`,\n`expand_recursively`, `expand_all_to_level`, `expand_to_level`, `collapse_doc_comments`,\n`expand_doc_comments`, `increase_font_size`, `decrease_font_size`, `complete_statement`, `unwrap`.", "type": "string" }, "level": { "description": "For `expand_all_to_level` and `expand_to_level`: the level, 1–5; for `unwrap`: which block,\n1 = the innermost (default 1).", "type": [ "integer", "null" ], "minimum": 0 }, "overwrite": { "description": "For `type`: overwrite mode — the text replaces as many characters after each caret as it\nhas itself, up to the line end, and may be longer than one character (default false).", "type": [ "boolean", "null" ] }, "first_visible_line": { "description": "For `context_info`: the first line in view, 1-based (default 1).", "type": [ "integer", "null" ], "minimum": 0 }, "shown_line": { "description": "For `context_info`: the line a previous call returned, to go on outwards from it.", "type": [ "integer", "null" ], "minimum": 0 }, "tab_size": { "description": "Columns a tab advances to, for `indents_to_spaces` and `indents_to_tabs`, 1–32\n(default 4).", "type": [ "integer", "null" ], "minimum": 0 }, "count": { "description": "How often `expand_word` or `expand_word_backward` is used in a row, 1–100 (default 1).", "type": [ "integer", "null" ], "minimum": 0 }, "carets": { "description": "Carets and selections.", "type": "array", "items": { "$ref": "#/$defs/CaretArg" } }, "text": { "description": "Character to type for `type`.", "type": [ "string", "null" ] }, "indent": { "description": "Indentation step (default four spaces).", "type": [ "string", "null" ] }, "comment_token": { "description": "Line comment token (default from the file's language).", "type": [ "string", "null" ] } }, "$defs": { "CaretArg": { "description": "A caret or selection for `editor_action` (1-based line and column, in characters).", "type": "object", "properties": { "line": { "description": "Line of the caret (selection end).", "type": "integer", "minimum": 0 }, "column": { "description": "Column of the caret.", "type": "integer", "minimum": 0 }, "anchor_line": { "description": "Line where the selection starts (default: no selection).", "type": [ "integer", "null" ], "minimum": 0 }, "anchor_column": { "description": "Column where the selection starts.", "type": [ "integer", "null" ], "minimum": 0 } }, "required": [ "line", "column" ] } }, "required": [ "path", "action", "carets" ], "type": "object"}