Edit

Get AL diagnostics - al_getdiagnostics

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

Parameter Type Default Description
scope "workspace" | "project" | "folder" | "file" "workspace" The scope from which to retrieve diagnostics.
filePath string Absolute path to a single .al file. Narrows results to that file.
folderPath string Absolute path to a folder. Returns diagnostics from all .al files in the folder recursively.
projectPath string Absolute path to an AL project folder. Returns diagnostics for all files in that project.
severities string[] All severities Filter by severity level: "error", "warning", "info", "hint".
areas string[] All areas Filter by diagnostic source area, for example "AL", "AppSourceCop", "CodeCop", "PerTenantExtensionCop".
limit integer 200 Maximum number of diagnostics to return. Maximum allowed value: 500.
includeRelatedInformation boolean false When true, includes related diagnostic information (secondary locations and context messages).

AL MCP Server

Parameter Type Default Description
filePath string Absolute path to a single .al or .dal file.
folderPath string Absolute path to a folder (recursive).
projectPath string Absolute path to an AL project folder.
severities string[] All severities Filter by severity: "error", "warning", "info", "hint".
areas string[] All areas Filter by diagnostic source area.
limit integer 200 Maximum number of diagnostics to return. Maximum allowed value: 500.

Return value

Visual Studio Code

The response includes:

Property Type Description
diagnostics array List of diagnostic items (see below).
counts object Summary counts: total, error, warning, info, hint.
truncated boolean true if there are more diagnostics than the specified limit.

Each item in diagnostics has:

Property Type Description
uri string File URI.
path string File system path.
severity string "error", "warning", "info", or "hint".
message string Human-readable diagnostic message.
source string Diagnostic source (for example, "AL", "AppSourceCop").
code string Diagnostic code (for example, "AL0118").
range object Start and end position in the file: { start: { line, character }, end: { line, character } }.
relatedInformation array Extra 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

Outcome Suggested action
No errors Proceed with al_publish to deploy the extension.
Errors reported Fix the reported issues and rebuild with al_build.
Many analyzer warnings Review 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