Skip to content

optimize_imports

MCP tools › Code insight and refactoring

Optimize Imports. Python: installed ruff (never downloaded) removes unused imports and sorts; without it only standalone imports the language server marks unused are removed, nothing sorted, __init__.py refused. JavaScript/TypeScript/Vue/Svelte: the language server's organize-imports actions (error without it). Both return changed, removed, left, by, sorted, summary and text. Java or Kotlin: removes unused, duplicate, java.lang and same-package imports, keeps wildcards, sorts in the reference's default layout; refuses comments between imports. Dry run by default; dry_run=false writes, refusing if the file changed.

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

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

Arguments

ArgumentTypeDescription
pathrequiredstringWorkspace-relative .java or .kt file (optimize_imports: also a Python, JavaScript, TypeScript, Vue or Svelte file).
dry_runbooleanOnly report the change (default true; optimize_imports only).

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 optimize_imports '{"path":"<string>"}'
Input schema as JSON
{
"type": "object",
"required": [
"path"
],
"properties": {
"path": {
"description": "Workspace-relative `.java` or `.kt` file (`optimize_imports`: also a Python, JavaScript,\nTypeScript, Vue or Svelte file).",
"type": "string"
},
"dry_run": {
"description": "Only report the change (default true; `optimize_imports` only).",
"type": [
"boolean",
"null"
]
}
}
}