get_code_fixes

[refactoring]

Lists available code fixes for diagnostics at a specific location.

Try this tool in Playground.

Parameters

NameTypeRequiredDescription
filePathstringYesFile path containing the diagnostic.
lineNumbernumberYes1-based line number.
columnnumberYes1-based column number.
diagnosticIdstringNoOptional diagnostic ID filter (e.g., 'CS0246').
projectNamestringNoOptional project name filter.
maxFixesnumberNoMax fixes per diagnostic. Default is 10.
includePreviewDiffbooleanNoInclude preview diff for each fix. Default is false.
maxPreviewDiffCharsnumberNoMax characters for preview diffs. Default is 2000.
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root).
timeout_msnumberNoTimeout in milliseconds. Use 0 to disable. Default is 30000.

Examples

Get code fixes at a location

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_code_fixes",
    "arguments": {
      "filePath": "/Users/dev/MyProject/Program.cs",
      "lineNumber": 10,
      "column": 15
    }
  }
}
Response
{
  "success": true,
  "data": {
    "filePath": "/path/to/File.cs",
    "lineNumber": 10,
    "column": 15,
    "diagnosticsAtLocation": 1,
    "totalFixesAvailable": 2,
    "diagnostics": [
      {
        "diagnosticId": "CS0246",
        "severity": "Error",
        "message": "The type or namespace name 'X' could not be found",
        "span": {
          "startLine": 10,
          "startColumn": 15,
          "endLine": 10,
          "endColumn": 16
        },
        "fixes": [
          {
            "fixId": "...",
            "title": "Add using ...",
            "equivalenceKey": "...",
            "previewDiff": null
          }
        ]
      }
    ]
  },
  "error": null
}

Response Notes

Returns fixes grouped by diagnostic at the location