al-test-runner-mcp-server
v1.0.6
Published
MCP server for running AL tests in Business Central
Maintainers
Readme
AL Test Runner MCP Server
A Model Context Protocol (MCP) server that exposes AL test execution capabilities for Business Central development. This server allows AI agents and MCP clients to discover AL tests in source code and run them against Business Central environments.
Features
- Test Discovery: Automatically scans AL workspace for test codeunits and methods
- Test Execution: Runs AL tests via PowerShell and returns structured results
- Configuration Management: Reads settings from
.altestrunner/config.jsonandlaunch.json
Prerequisites
- Node.js >= 18.0.0
- PowerShell (Windows)
- Business Central environment (local container or remote)
- AL Test Runner VS Code extension PowerShell modules
- Pre-configured
.altestrunner.jsonwith credentials
Installation
npm install al-test-runner-mcp-serverConfiguration with MCP Clients
Add to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"al-test-runner": {
"command": "npx",
"args": ["[email protected]"]
}
}
}Available Tools
1. discover_al_tests
Discovers all AL test codeunits and methods in a workspace.
Parameters:
workspacePath(string, required): Absolute path to the AL workspace directory
Example Request:
{
"name": "discover_al_tests",
"arguments": {
"workspacePath": "C:\\Projects\\MyBCApp"
}
}Example Response:
{
"success": true,
"testCodeunitsFound": 5,
"totalTestMethods": 42,
"testCodeunits": [
{
"id": 50100,
"name": "Sales Invoice Tests",
"filePath": "C:\\Projects\\MyBCApp\\test\\SalesInvoiceTests.al",
"methods": [
{
"name": "TestCreateSalesInvoice",
"lineNumber": 15
},
{
"name": "TestPostSalesInvoice",
"lineNumber": 28
}
]
}
]
}2. run_al_tests
Executes AL tests in Business Central and returns results.
Parameters:
workspacePath(string, required): Absolute path to the AL workspace directorycodeunitId(number, optional): ID of specific test codeunit to runmethodName(string, optional): Name of specific test method (requires codeunitId)containerName(string, optional): Name of the Docker container to run tests againstuserName(string, optional): Username for BC authenticationcompanyName(string, optional): Company name to run tests against
Example Request (Run All Tests):
{
"name": "run_al_tests",
"arguments": {
"workspacePath": "C:\\Projects\\MyBCApp"
}
}Example Request (Run Specific Test):
{
"name": "run_al_tests",
"arguments": {
"workspacePath": "C:\\Projects\\MyBCApp",
"codeunitId": 50100,
"methodName": "TestCreateSalesInvoice"
}
}Example Response:
{
"success": true,
"exitCode": 0,
"stdout": "Running tests...\nTests completed.",
"stderr": "",
"results": {
"total": 2,
"passed": 2,
"failed": 0,
"skipped": 0,
"duration": 1.234,
"results": [
{
"codeunitId": 50100,
"codeunitName": "Sales Invoice Tests",
"methodName": "TestCreateSalesInvoice",
"result": "Pass",
"duration": 0.567
},
{
"codeunitId": 50100,
"codeunitName": "Sales Invoice Tests",
"methodName": "TestPostSalesInvoice",
"result": "Pass",
"duration": 0.667
}
]
}
}3. get_test_configuration
Retrieves the current test configuration from workspace files.
Parameters:
workspacePath(string, required): Absolute path to the AL workspace directory
Example Request:
{
"name": "get_test_configuration",
"arguments": {
"workspacePath": "C:\\Projects\\MyBCApp"
}
}Example Response:
{
"success": true,
"alTestRunnerConfig": {
"containerName": "bcserver",
"userName": "admin",
"password": "password"
"companyName": "CRONUS International Ltd.",
},
"appJson": {
"id": "12345678-1234-1234-1234-123456789012",
"name": "My BC App",
"version": "1.0.0.0"
}
}Configuration Files
.altestrunner.json
Required configuration file in your AL workspace:
{
"containerName": "bcserver",
"userName": "admin",
"password": "password for NavUserPassword auth",
"companyName": "Company Name to run tests in"
}License
MIT
Author
James Pearson
