get_diagnostics

[diagnostics]

Gets compiler diagnostics (warnings, errors, info) for the loaded solution.

Parameters

NameTypeRequiredDescription
filePathstringNoLimit diagnostics to a specific file path.
projectNamestringNoLimit diagnostics to a specific project.
severitystringNoMinimum severity: error, warning, info, hidden.

Examples

Get diagnostics with default severity

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,
    "diagnostics": [
      {
        "id": "CS1002",
        "severity": "Error",
        "message": "; expected",
        "filePath": "/path/to/File.cs",
        "lineNumber": 42,
        "column": 17,
        "endLineNumber": 42,
        "endColumn": 18,
        "category": "Syntax",
        "projectName": "MyProject"
      }
    ]
  },
  "error": null
}

Get errors for a specific file

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

Response

Returns diagnostics grouped by severity with location details

Go to Playground to test this tool interactively.