organize_imports
[codefix]
Organizes TypeScript or JavaScript imports with TypeScript language-service edits.
Before you use this tool
Previews edits by default. Application changes live documents. Use write_file to save the result to disk.
Try it locally in the TGlider playground
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| filePath | string | Yes | Workspace-relative or absolute file path. |
| applyChanges | boolean | No | Apply organize-import edits to live workspace state instead of returning preview only. Default: false |
| includeDiff | boolean | No | Include a unified diff in the response. Default: true |
| maxDiffChars | number | No | Maximum diff characters to return before truncating. Default: 50000 |
| skipDestructiveCodeActions | boolean | No | Sort and combine imports without removing unused imports. Default: false |
Examples
Replace sample paths and symbol keys with values from your workspace.
Preview import organization edits
Arguments
{
"filePath": "src/app.ts"
}Full MCP request
Full MCP request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "organize_imports",
"arguments": {
"filePath": "src/app.ts"
}
}
}Response Notes
Returns organize-import edits, preview diff metadata, live-document version state, and whether changes were applied.