Get AL diagnostics - algetdiagnostics

Applies to: AL Language extension 17.0 and later | Available in: Visual Studio Code, AL MCP Server

The al_getdiagnostics tool retrieves AL compilation diagnostics—errors, warnings, informational messages, and hints—with flexible filtering by scope, severity, source area, file, or folder.

  • In Visual Studio Code, diagnostics are read from the Problems panel, which reflects the current state of the AL Language Server.
  • In AL MCP, diagnostics come directly from the compiler output.

Use 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.

Parameters

Visual Studio Code

ParameterTypeDefaultDescription
scope"workspace" | "project" | "folder" | "file""workspace"The scope from which to retrieve diagnostics.
filePathstring—Absolute path to a single .al file. Narrows results to that file.
folderPathstring—Absolute path to a folder. Returns diagnostics from all .al files in the folder recursively.
projectPathstring—Absolute path to an AL project folder. Returns diagnostics for all files in that project.
severitiesstring[]All severitiesFilter by severity level: "error", "warning", "info", "hint".
areasstring[]All areasFilter by diagnostic source area, for example "AL", "AppSourceCop", "CodeCop", "PerTenantExtensionCop".
limitinteger200Maximum number of diagnostics to return. Maximum allowed value: 500.
includeRelatedInformationbooleanfalseWhen true, includes related diagnostic information (secondary locations and context messages).

AL MCP Server

ParameterTypeDefaultDescription
filePathstring—Absolute path to a single .al or .dal file.
folderPathstring—Absolute path to a folder (recursive).
projectPathstring—Absolute path to an AL project folder.
severitiesstring[]All severitiesFilter by severity: "error", "warning", "info", "hint".
areasstring[]All areasFilter by diagnostic source area.
limitinteger200Maximum number of diagnostics to return. Maximum allowed value: 500.

Return value

Visual Studio Code

The response includes:

PropertyTypeDescription
diagnosticsarrayList of diagnostic items (see below).
countsobjectSummary counts: total, error, warning, info, hint.
truncatedbooleantrue if there are more diagnostics than the specified limit.

Each item in diagnostics has:

PropertyTypeDescription
uristringFile URI.
pathstringFile system path.
severitystring"error", "warning", "info", or "hint".
messagestringHuman-readable diagnostic message.
sourcestringDiagnostic source (for example, "AL", "AppSourceCop").
codestringDiagnostic code (for example, "AL0118").
rangeobjectStart and end position in the file: { start: { line, character }, end: { line, character } }.
relatedInformationarrayExtra context, when includeRelatedInformation: true.

AL MCP Server

Each item in diagnostics has: file, severity, message, code, and a location string (file and line number).

Examples

Get all errors in the workspace (Visual Studio Code)

In Copilot Chat: "Show me all errors in the project."

Copilot calls al_getdiagnostics with scope="project" and severities=["error"].

Check for AppSourceCop violations (Visual Studio Code)

{
  "severities": ["error", "warning"],
  "areas": ["AppSourceCop"]
}

Get errors in a specific file (Visual Studio Code)

{
  "scope": "file",
  "filePath": "C:/repos/MyExtension/src/CustomerCard.Page.al",
  "severities": ["error"]
}

Get all diagnostics for a project (AL MCP)

{
  "projectPath": "C:/repos/MyExtension"
}

Get only errors in a folder (AL MCP)

{
  "folderPath": "C:/repos/MyExtension/src",
  "severities": ["error"]
}

Check AppSourceCop violations with a high limit (AL MCP)

{
  "projectPath": "C:/repos/MyExtension",
  "areas": ["AppSourceCop"],
  "limit": 500
}

Suggested next steps

OutcomeSuggested action
No errorsProceed with al_publish to deploy the extension.
Errors reportedFix the reported issues and rebuild with al_build.
Many analyzer warningsReview the list and configure or suppress individual rules as appropriate.
  • al_build — Build the project; errors are returned in the build result and also appear in diagnostics.
  • al_compile — Compile without building; faster validation (AL MCP only).
  • al_symbolsearch — Search for the symbol referenced in an error to understand its definition.

AI agent tools overview
AL MCP Server reference