get_diagnostics

[diagnostics]

Gets diagnostics (warnings, errors) for the loaded solution/project. Use includeAnalyzers=true to include analyzer/IDE diagnostics.

Try this tool in Playground.

Parameters

NameTypeRequiredDescription
filePathstringNoOptional file path filter.
projectNamestringNoOptional project name filter.
includeAnalyzersbooleanNoInclude analyzer/IDE diagnostics. Default is false.
summaryOnlybooleanNoWhen true, returns summary counts only. Default is false.
severitystringNoMinimum severity: 'error', 'warning', 'info', or 'hidden'. Default is 'warning'.
categorystringNoOptional category filter (e.g., 'Compiler', 'Style').
idPrefixstringNoOptional diagnostic ID prefix filter (e.g., 'CS', 'CA', 'IDE').
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root).
sortBystringNoOptional sort: 'severity', 'filePath', 'id', 'lineNumber', 'projectName'.
sortOrderstringNoSort order: 'asc' (default) or 'desc'.
skipnumberNoPagination offset. Default is 0.
takenumberNoPagination size. Default is 200.
timeout_msnumberNoTimeout in milliseconds (5 minutes). Use 0 to disable. Default is 300000.

Examples

Get warnings and errors (default)

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_diagnostics",
    "arguments": {}
  }
}
Response
{
  "success": true,
  "data": {
    "diagnosticCount": 3,
    "errorCount": 1,
    "warningCount": 2,
    "infoCount": 0,
    "paging": {
      "skip": 0,
      "take": 200,
      "returned": 3,
      "total": 3
    },
    "diagnostics": [
      {
        "id": "CS1002",
        "severity": "Error",
        "message": "; expected",
        "filePath": "/path/to/File.cs",
        "lineNumber": 42,
        "column": 17,
        "endLineNumber": 42,
        "endColumn": 18,
        "category": "Syntax",
        "projectName": "MyProject"
      }
    ]
  },
  "meta": {
    "durationMs": 123,
    "cancelled": false,
    "timedOut": false,
    "timeoutMs": 300000
  },
  "error": null
}

Get error diagnostics only

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_diagnostics",
    "arguments": {
      "severity": "error"
    }
  }
}
Response
{
  "success": true,
  "data": {
    "diagnosticCount": 3,
    "errorCount": 1,
    "warningCount": 2,
    "infoCount": 0,
    "paging": {
      "skip": 0,
      "take": 200,
      "returned": 3,
      "total": 3
    },
    "diagnostics": [
      {
        "id": "CS1002",
        "severity": "Error",
        "message": "; expected",
        "filePath": "/path/to/File.cs",
        "lineNumber": 42,
        "column": 17,
        "endLineNumber": 42,
        "endColumn": 18,
        "category": "Syntax",
        "projectName": "MyProject"
      }
    ]
  },
  "meta": {
    "durationMs": 123,
    "cancelled": false,
    "timedOut": false,
    "timeoutMs": 300000
  },
  "error": null
}

Summary view by project and severity

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_diagnostics",
    "arguments": {
      "summaryOnly": true,
      "severity": "warning"
    }
  }
}
Response
{
  "success": true,
  "data": {
    "diagnosticCount": 3,
    "errorCount": 1,
    "warningCount": 2,
    "infoCount": 0,
    "paging": {
      "skip": 0,
      "take": 200,
      "returned": 3,
      "total": 3
    },
    "diagnostics": [
      {
        "id": "CS1002",
        "severity": "Error",
        "message": "; expected",
        "filePath": "/path/to/File.cs",
        "lineNumber": 42,
        "column": 17,
        "endLineNumber": 42,
        "endColumn": 18,
        "category": "Syntax",
        "projectName": "MyProject"
      }
    ]
  },
  "meta": {
    "durationMs": 123,
    "cancelled": false,
    "timedOut": false,
    "timeoutMs": 300000
  },
  "error": null
}

Response Notes

Returns diagnostics, optionally with paging and filtering