{"title":"Get AL diagnostics - algetdiagnostics","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/al-agent-tools/al-tool-get-diagnostics/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/al-agent-tools/al-tool-get-diagnostics, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/al-agent-tools/al-tool-get-diagnostics","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Learn about the al_getdiagnostics tool available for AL development, including how to use it in Visual Studio Code with GitHub Copilot and through the AL MCP Server for headless environments and CI/CD pipelines.","date":"2026-10-02","meta":{"topic":"concept-article"},"outline":[{"level":1,"title":"Get AL diagnostics - al_getdiagnostics","slug":"get-al-diagnostics---al_getdiagnostics","at":0,"chars":4818},{"level":2,"title":"Parameters","slug":"parameters","at":733,"chars":1460},{"level":3,"title":"Visual Studio Code","slug":"visual-studio-code","at":747,"chars":959},{"level":3,"title":"AL MCP Server","slug":"al-mcp-server","at":1706,"chars":487},{"level":2,"title":"Return value","slug":"return-value","at":2193,"chars":950},{"level":3,"title":"Visual Studio Code","slug":"visual-studio-code-1","at":2209,"chars":809},{"level":3,"title":"AL MCP Server","slug":"al-mcp-server-1","at":3018,"chars":125},{"level":2,"title":"Examples","slug":"examples","at":3143,"chars":918},{"level":3,"title":"Get all errors in the workspace (Visual Studio Code)","slug":"get-all-errors-in-the-workspace-visual-studio-code","at":3155,"chars":194},{"level":3,"title":"Check for AppSourceCop violations (Visual Studio Code)","slug":"check-for-appsourcecop-violations-visual-studio-code","at":3349,"chars":141},{"level":3,"title":"Get errors in a specific file (Visual Studio Code)","slug":"get-errors-in-a-specific-file-visual-studio-code","at":3490,"chars":179},{"level":3,"title":"Get all diagnostics for a project (AL MCP)","slug":"get-all-diagnostics-for-a-project-al-mcp","at":3669,"chars":103},{"level":3,"title":"Get only errors in a folder (AL MCP)","slug":"get-only-errors-in-a-folder-al-mcp","at":3772,"chars":127},{"level":3,"title":"Check AppSourceCop violations with a high limit (AL MCP)","slug":"check-appsourcecop-violations-with-a-high-limit-al-mcp","at":3899,"chars":162},{"level":2,"title":"Suggested next steps","slug":"suggested-next-steps","at":4061,"chars":305},{"level":2,"title":"Related tools","slug":"related-tools","at":4366,"chars":342},{"level":2,"title":"Related information","slug":"related-information","at":4708,"chars":110}],"text":"# Get AL diagnostics - al_getdiagnostics\nApplies to: AL Language extension 17.0 and later | Available in: Visual Studio Code, AL MCP Server\nThe al_getdiagnostics tool retrieves AL compilation diagnostics-errors, warnings, informational messages, and hints-with flexible filtering by scope, severity, source area, file, or folder.\n In Visual Studio Code, diagnostics are read from the Problems panel, which reflects the current state of the AL Language Server.\n In AL MCP, diagnostics come directly from the compiler output.\nUse this tool after a build or compilation to inspect what needs to be fixed, to check whether a project is error-free, or to monitor code quality by filtering for specific diagnostic codes or analyzer areas.\n## Parameters\n### Visual Studio Code\nParameter|Type|Default|Description\nscope|`\"workspace\"` \\| `\"project\"` \\| `\"folder\"` \\| `\"file\"`|`\"workspace\"`|The scope from which to retrieve diagnostics.\nfilePath|string|-|Absolute path to a single `.al` file. Narrows results to that file.\nfolderPath|string|-|Absolute path to a folder. Returns diagnostics from all `.al` files in the folder recursively.\nprojectPath|string|-|Absolute path to an AL project folder. Returns diagnostics for all files in that project.\nseverities|string[]|All severities|Filter by severity level: `\"error\"`, `\"warning\"`, `\"info\"`, `\"hint\"`.\nareas|string[]|All areas|Filter by diagnostic source area, for example `\"AL\"`, `\"AppSourceCop\"`, `\"CodeCop\"`, `\"PerTenantExtensionCop\"`.\nlimit|integer|`200`|Maximum number of diagnostics to return. Maximum allowed value: `500`.\nincludeRelatedInformation|boolean|false|When true, includes related diagnostic information (secondary locations and context messages).\n### AL MCP Server\nParameter|Type|Default|Description\nfilePath|string|-|Absolute path to a single `.al` or `.dal` file.\nfolderPath|string|-|Absolute path to a folder (recursive).\nprojectPath|string|-|Absolute path to an AL project folder.\nseverities|string[]|All severities|Filter by severity: `\"error\"`, `\"warning\"`, `\"info\"`, `\"hint\"`.\nareas|string[]|All areas|Filter by diagnostic source area.\nlimit|integer|`200`|Maximum number of diagnostics to return. Maximum allowed value: `500`.\n## Return value\n### Visual Studio Code\nThe response includes:\nProperty|Type|Description\ndiagnostics|array|List of diagnostic items (see below).\ncounts|object|Summary counts: total, error, warning, info, hint.\ntruncated|boolean|true if there are more diagnostics than the specified limit.\nEach item in diagnostics has:\nProperty|Type|Description\nuri|string|File URI.\npath|string|File system path.\nseverity|string|`\"error\"`, `\"warning\"`, `\"info\"`, or `\"hint\"`.\nmessage|string|Human-readable diagnostic message.\nsource|string|Diagnostic source (for example, `\"AL\"`, `\"AppSourceCop\"`).\ncode|string|Diagnostic code (for example, `\"AL0118\"`).\nrange|object|Start and end position in the file: `{ start: { line, character }, end: { line, character } }`.\nrelatedInformation|array|Extra context, when `includeRelatedInformation: true`.\n### AL MCP Server\nEach item in diagnostics has: file, severity, message, code, and a location string (file and line number).\n## Examples\n### Get all errors in the workspace (Visual Studio Code)\nIn Copilot Chat: \"Show me all errors in the project.\"\nCopilot calls al_getdiagnostics with `scope=\"project\"` and `severities=[\"error\"]`.\n### Check for AppSourceCop violations (Visual Studio Code)\n```json\n{\n  \"severities\": [\"error\", \"warning\"],\n  \"areas\": [\"AppSourceCop\"]\n}\n```\n### Get errors in a specific file (Visual Studio Code)\n```json\n{\n  \"scope\": \"file\",\n  \"filePath\": \"C:/repos/MyExtension/src/CustomerCard.Page.al\",\n  \"severities\": [\"error\"]\n}\n```\n### Get all diagnostics for a project (AL MCP)\n```json\n{\n  \"projectPath\": \"C:/repos/MyExtension\"\n}\n```\n### Get only errors in a folder (AL MCP)\n```json\n{\n  \"folderPath\": \"C:/repos/MyExtension/src\",\n  \"severities\": [\"error\"]\n}\n```\n### Check AppSourceCop violations with a high limit (AL MCP)\n```json\n{\n  \"projectPath\": \"C:/repos/MyExtension\",\n  \"areas\": [\"AppSourceCop\"],\n  \"limit\": 500\n}\n```\n## Suggested next steps\nOutcome|Suggested action\nNo errors|Proceed with al_publish<al-tool-publish> to deploy the extension.\nErrors reported|Fix the reported issues and rebuild with al_build<al-tool-build>.\nMany analyzer warnings|Review the list and configure or suppress individual rules as appropriate.\n## Related tools\n al_build<al-tool-build> - Build the project; errors are returned in the build result and also appear in diagnostics.\n al_compile<al-tool-compile> - Compile without building; faster validation (AL MCP only).\n al_symbolsearch<al-tool-symbol-search> - Search for the symbol referenced in an error to understand its definition.\n## Related information\nAI agent tools overview<al-agent-tools-overview>\nAL MCP Server reference<al-mcp-server>"}