Browse documentation

organize_usings

[codefix]

Organizes using directives in a C# file (sort + remove unused) and returns diff output.

Before you use this tool

Writes files by default. An authorized, unambiguous edit with a clear scope can apply directly. Set applyChanges: false for a preview without file writes. Preview when the user requests inspection only, the scope is unclear, or a broad refactor needs inspection.

Try it locally in the Glider playground

Parameters

NameTypeRequiredDescription
filePathstringYesFile path to organize. Absolute, loaded-root-relative, or repository-relative.
projectNamestringNoOptional project name filter.
applyChangesbooleanNoIf true (default), applies changes to disk. If false, returns preview only. Default: true
includeDiffbooleanNoInclude unified diff in response. Default is true. Default: true
maxDiffCharsnumberNoMax diff characters. Use 0 for unlimited. Default is 50000. Default: 50000
includePerFileDiffbooleanNoInclude diffs in changedFiles independently of includeDiff. File paths and counts remain available when false. Unreleased: development builds after 13.4.0. Use only when the installed schema advertises this parameter. Default: false
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root). Default: "absolute"
responseDetailstringNocompact returns results and actionable state. full adds diagnostic metadata under responseDiagnostics. Default: "compact"

Examples

Replace sample paths and symbol keys with values from your workspace.

Preview organize usings

Arguments
{
  "filePath": "/Users/dev/MyProject/Program.cs",
  "applyChanges": false
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "organize_usings",
    "arguments": {
      "filePath": "/Users/dev/MyProject/Program.cs",
      "applyChanges": false
    }
  }
}
Illustrative response
{
  "success": true,
  "filePath": "/path/to/File.cs",
  "changed": true,
  "applied": false,
  "filesChanged": 1,
  "unifiedDiff": "...",
  "changedFiles": [
    {
      "filePath": "/path/to/File.cs",
      "changeCount": 1
    }
  ]
}

Response Notes

Returns the changed file metadata and diff output.

Unreleased development builds after 13.4.0 return one unified diff by default; the example uses that contract. Follow the installed schema for supported parameters and defaults. Set includeDiff=false for compact output, with includePerFileDiff=false where supported. Set includePerFileDiff=true only when separate file diffs are needed; it works independently of includeDiff. These controls preserve application state, file metadata, counts, and any diagnostics, errors, conflicts, or limits the tool reports. Results use top-level fields with success. Compact is the default; full adds responseDiagnostics. Both modes retain errors, coverage, partial state, and recovery advice.