[refactoring]
Applies a specific code fix (or returns a preview) and returns diff output.
Try this tool in Playground.
| Name | Type | Required | Description |
|---|---|---|---|
| filePath | string | Yes | File path containing the diagnostic. |
| lineNumber | number | Yes | 1-based line number. |
| column | number | Yes | 1-based column number. |
| fixId | string | Yes | Fix ID from get_code_fixes. |
| applyChanges | boolean | No | If true (default), applies changes to disk. If false, returns preview only. |
| includeDiff | boolean | No | Include unified diff in response. Default is true. |
| maxDiffChars | number | No | Max diff characters. Use 0 for unlimited. Default is 50000. |
| includePerFileDiff | boolean | No | Include per-file diffs. Default is true. |
| pathStyle | string | No | Path style: 'absolute' (default) or 'relative' (to solution root). |
| timeout_ms | number | No | Timeout in milliseconds. Use 0 to disable. Default is 60000. |
Preview applying a code fix
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "apply_code_fix",
"arguments": {
"filePath": "/Users/dev/MyProject/Program.cs",
"lineNumber": 10,
"column": 15,
"fixId": "...",
"applyChanges": false
}
}
}{
"success": true,
"data": {
"fixId": "...",
"title": "Add using ...",
"applied": false,
"filesChanged": 1,
"unifiedDiff": "...",
"changedFiles": [
{
"filePath": "/path/to/File.cs",
"changeCount": 1,
"diff": "..."
}
]
},
"error": null
}Returns diff output and per-file diffs when enabled