Compile AL project - alcompile

Applies to: AL Language extension 17.0 and later | Available in: AL MCP Server only

The al_compile tool compiles the AL workspace and returns diagnostics without generating an .app package. Because it skips the packaging step, it's faster than al_build and is the preferred choice for validation-only scenarios such as pull-request checks, precommit gates, and quick iterative feedback loops.

Use al_build instead when you need the .app file—for example, before publishing.

Note

al_compile is available on the AL MCP Server only. In Visual Studio Code, use al_build with scope="current" for an equivalent result.

Parameters

All parameters are optional and are passed as properties of a single options object.

ParameterTypeDefaultDescription
onlyErrorsbooleantrueWhen true (the default), only error-severity diagnostics are returned. Set to false to also receive warnings, informational messages, and hints.
maxDiagnosticsPerCompilationinteger100Maximum number of diagnostics to return per compilation. Increase this value if you expect a large number of issues.
enableCodeAnalysisboolean(server default)Enable AL code analyzers during compilation. When enabled, the analyzers listed in codeAnalyzers are run.
codeAnalyzersstring[](server default)List of code analyzers to run. Supported values: ${CodeCop}, ${AppSourceCop}, ${PerTenantExtensionCop}, ${UICop}.

Return value

The tool returns a compilation result object with the following properties:

PropertyTypeDescription
Succeededbooleantrue if the compilation completed with no errors.
DiagnosticsarrayList of diagnostic items. Each item contains Severity, Code (for example, AL0118), Location (file and line), and Description (human-readable message).
MessagestringOptional extra context about the compilation result.

Examples

Validate the current workspace (errors only)

{}

The default behavior returns only errors, which is suitable for pass/fail gates.

Validate with all diagnostics and code analysis

{
  "onlyErrors": false,
  "enableCodeAnalysis": true,
  "codeAnalyzers": ["${CodeCop}", "${AppSourceCop}"]
}

Limit output in a large workspace

{
  "maxDiagnosticsPerCompilation": 50
}

Diagnostics format

Each item in the Diagnostics array has the following structure:

{
  "Severity": "Error",
  "Code": "AL0118",
  "Location": "MyCodeunit.al(42,15)",
  "Description": "The name 'MyVariable' does not exist in the current context."
}

Suggested next steps

OutcomeSuggested action
No errorsProceed with al_build to generate the .app package.
Errors reportedFix the reported issues and rerun al_compile.
Symbols not foundRun al_downloadsymbols to refresh the symbol packages.

AI agent tools overview
AL MCP Server reference