AL MCP & Test Skills¶
Until now the agent could write code and see compiler errors — but it couldn't run tests. You've been doing that manually: publish, run the test tool, copy failures back.
This page sets up two tools that automate that loop for every feature from here on.
AL MCP — what it does¶
Once connected, the agent can build, read diagnostics, and run tests without you intervening. The implement → build → test → fix cycle runs autonomously.
run-al-tests skill — why you also need it¶
AL MCP's al_run_tests currently does not support UI tests — tests that open a TestPage and navigate to a record will fail, even when the code is correct. This is a known limitation reported to Microsoft: the AL MCP opens each test in a separate client session, so data created inside the test isn't visible to the TestPage.
The run-al-tests skill uses BcContainerHelper with the standard BC test runner, which runs everything in a single shared session. All tests pass.
The pattern: AL MCP drives the implement loop. run-al-tests confirms before merge.
Set up AL MCP¶
Prerequisites: .NET 8 runtime installed. BC container on Windows authentication (required for al_run_tests).
1. Add altool to PATH — run once in PowerShell:
$altoolDir = (Get-ChildItem "$env:USERPROFILE\.vscode\extensions" -Filter "ms-dynamics-smb.al-*" -Directory | Sort-Object Name -Descending | Select-Object -First 1).FullName + "\bin\win32"
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($currentPath -notlike "*$altoolDir*") {
[Environment]::SetEnvironmentVariable("PATH", "$altoolDir;$currentPath", "User")
Write-Host "Added to PATH: $altoolDir"
} else { Write-Host "Already in PATH" }
2. Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"al": {
"command": "altool",
"args": ["launchmcpserver", "--transport", "stdio"]
}
}
}
3. Full restart (not just Reload Window).
Check Cursor Settings → Tools & Integrations → MCP — green dot, tools listed.
1. Verify altool version matches your AL extension:
If the wrong version runs, ensure the AL 18 bin folder is first in your PATH (same script as the Cursor tab).
2. Create or edit mcp.json globally:
{
"mcpServers": {
"al": {
"command": "altool",
"args": ["launchmcpserver", "--transport", "stdio"]
}
}
}
3. Reload Window (Ctrl+Shift+P → Developer: Reload Window).
Check GitHub Copilot Chat → Agent mode — AL tools should be available.
Verify¶
MCP settings should list: al_addproject, al_compile, al_build, al_getdiagnostics, al_symbolsearch, al_downloadsymbols, al_publish, al_run_tests, al_auth_login, al_auth_logout.
launch.json for tests¶
al_run_tests reads from test/.vscode/launch.json. Must be Windows authentication and startupCompany must be set to the company you want to test:
{
"configurations": [{
"type": "al",
"request": "launch",
"name": "Local Sandbox (bc-28)",
"server": "http://bc-28",
"serverInstance": "BC",
"port": 7049,
"tenant": "default",
"authentication": "Windows",
"startupCompany": "CRONUS USA, Inc."
}]
}
Reference
run-al-tests skill¶
Ships with the repo at .cursor/skills/run-al-tests/. To use it, just ask the agent to run the run-al-tests skill.
Test comparison¶
| AL MCP | run-al-tests skill |
BC Test Tool | |
|---|---|---|---|
| Uses AL test runner | No | Yes | Yes |
| TestPage tests | May fail | Pass | Pass |
| CI-friendly | Yes | Yes | No |