Skip to content

format_file

MCP tools › Code insight and refactoring

Format a workspace file (or a range) as Reformat Code does. A whole file of a trusted project with node_modules/.bin/prettier uses Prettier and its config; Python uses an installed ruff or black (nothing is installed; else it names what to install); SQL and Markdown without Prettier are formatted by Ferris IDEA (whitespace only, whole files); otherwise the language server formats. formatter and code_style say what applied; indentation follows .editorconfig, the project code style or Code Style. Unformattable files give an error saying why. Dry run unless dry_run false, which refuses if the file changed since.

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

Capabilitycode.format_file
AreaCode insight and refactoring
Accesschanges files
Reachesprocess
Rightswrite, trusted-project
Dry rundry_run, on unless the call turns it off

Arguments

ArgumentTypeDescription
pathrequiredstringWorkspace-relative file path.
rangearray of integerOnly format this range: [start line, start character, end line, end character], 0-based.minItems 4 · maxItems 4
tab_sizeintegerIndentation width (default: the file's .editorconfig, else Code Style for its language — 2 for JSON, YAML, SCSS and Less, 4 for most others; the project's formatter configuration may override it).minimum 0
insert_spacesbooleanSpaces instead of tabs (default: as for tab_size; tabs for Go).
dry_runbooleanOnly report the edits (default true).

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 format_file '{"path":"<string>"}'
Input schema as JSON
{
"type": "object",
"required": [
"path"
],
"properties": {
"path": {
"description": "Workspace-relative file path.",
"type": "string"
},
"range": {
"description": "Only format this range: [start line, start character, end line, end character], 0-based.",
"type": [
"array",
"null"
],
"items": {
"type": "integer",
"minimum": 0
},
"minItems": 4,
"maxItems": 4
},
"tab_size": {
"description": "Indentation width (default: the file's `.editorconfig`, else Code Style for its language —\n2 for JSON, YAML, SCSS and Less, 4 for most others; the project's formatter configuration\nmay override it).",
"type": [
"integer",
"null"
],
"minimum": 0
},
"insert_spaces": {
"description": "Spaces instead of tabs (default: as for `tab_size`; tabs for Go).",
"type": [
"boolean",
"null"
]
},
"dry_run": {
"description": "Only report the edits (default true).",
"type": [
"boolean",
"null"
]
}
}
}