[diagnostics]
Gets diagnostics (warnings, errors) for the loaded solution/project. Use includeAnalyzers=true to include analyzer/IDE diagnostics.
Try this tool in Playground.
| Name | Type | Required | Description |
|---|---|---|---|
| filePath | string | No | Optional file path filter. |
| projectName | string | No | Optional project name filter. |
| includeAnalyzers | boolean | No | Include analyzer/IDE diagnostics. Default is false. |
| summaryOnly | boolean | No | When true, returns summary counts only. Default is false. |
| severity | string | No | Minimum severity: 'error', 'warning', 'info', or 'hidden'. Default is 'warning'. |
| category | string | No | Optional category filter (e.g., 'Compiler', 'Style'). |
| idPrefix | string | No | Optional diagnostic ID prefix filter (e.g., 'CS', 'CA', 'IDE'). |
| pathStyle | string | No | Path style: 'absolute' (default) or 'relative' (to solution root). |
| sortBy | string | No | Optional sort: 'severity', 'filePath', 'id', 'lineNumber', 'projectName'. |
| sortOrder | string | No | Sort order: 'asc' (default) or 'desc'. |
| skip | number | No | Pagination offset. Default is 0. |
| take | number | No | Pagination size. Default is 200. |
| timeout_ms | number | No | Timeout in milliseconds (5 minutes). Use 0 to disable. Default is 300000. |
Get warnings and errors (default)
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_diagnostics",
"arguments": {}
}
}{
"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
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_diagnostics",
"arguments": {
"severity": "error"
}
}
}{
"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
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_diagnostics",
"arguments": {
"summaryOnly": true,
"severity": "warning"
}
}
}{
"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
}Returns diagnostics, optionally with paging and filtering