Companion code for the article How to Use AI and MCP to Automate Your Shop Floor in Business Central.
The one-line idea: Business Central does not talk to AI agents out of the box. You build a bridge — custom AL API pages that expose manufacturing data the way a planner thinks about it, plus a small Model Context Protocol (MCP) server that lets an agent (Claude, Copilot Studio, Azure OpenAI, …) query and act on that data in plain language.
This repo is that bridge, end to end, as a working example you can read, run, and adapt.
┌─────────────┐ natural language ┌──────────────┐ HTTPS + OAuth2 ┌──────────────────┐
│ AI agent │ ───────────────────────► │ MCP server │ ───────────────────► │ Business Central │
│ (Claude) │ ◄─────────────────────── │ (TypeScript) │ ◄─────────────────── │ custom AL API │
└─────────────┘ "which machine is the └──────────────┘ /api/gmsoft/... └──────────────────┘
bottleneck today?" tools production orders,
work centres, actions
| Folder | What it is | Language |
|---|---|---|
al-extension/ |
The bridge inside BC — custom API pages that expose production orders and work-centre load with pre-computed signals (isOverdue, completionPct, loadPct), plus an OData action codeunit to release/replan orders safely. |
AL |
mcp-server/ |
The MCP server — a small Node/TypeScript server that authenticates to BC with OAuth2 client credentials and exposes a handful of MCP tools an agent can call. | TypeScript |
prompts/ |
Example shop-floor prompts that map to the tools, and what good answers look like. | Markdown |
docs/ |
Setup guide — register the Entra (Azure AD) app, publish the AL API, wire the MCP server, connect Claude Desktop. | Markdown |
examples/ |
Ready-to-paste client config (claude_desktop_config.json) and a worked "daily briefing" walkthrough. |
JSON / Markdown |
The temptation is to expose raw BC tables and let the AI "figure it out". That is slow, expensive in tokens, and fragile. The pattern this repo demonstrates is the opposite:
- Do the manufacturing logic in AL, where the data lives. Is an order overdue? What % complete is it? Is a work centre over 90% loaded? Compute it in
OnAfterGetRecord, expose it as a clean boolean/number. - Give the agent decisions, not rows.
isOverdue = trueis a decision. A due date and a quantity table is homework. - Keep actions safe and validated. Status changes (Firm Planned → Released) go through an OData action that runs BC's own validation, so the agent can act, not just read, without bypassing business rules.
That is what turns "a 40-minute manual morning briefing" into "a 10-second question".
# 1. Publish the AL extension to your BC sandbox (see al-extension/README.md)
# -> exposes /api/gmsoft/manufacturing/v1.0/...
# 2. Configure and run the MCP server
cd mcp-server
cp .env.example .env # fill in tenant, BC URL, client id/secret
npm install
npm run build
npm start # or wire it into Claude Desktop (see examples/)Full, step-by-step instructions: docs/setup.md.
| MCP tool | What it answers / does | Backed by |
|---|---|---|
list_production_orders |
"Show me the late orders for Work Center 2." | productionOrders API page |
get_work_center_load |
"Which machine is our bottleneck today?" | workCenterLoad API page |
get_shop_floor_briefing |
"Give me the morning shop-floor briefing." | both pages, summarised |
release_production_order |
"Release order 1001102 to production." | ShopFloorActions OData action |
This is example / teaching code, MIT-licensed, meant to be read and adapted — not a packaged product. The AL objects use ID range 50400–50499. Field names on standard manufacturing tables can vary slightly by BC version; the code is written for BC v27+ and commented where a version check is worth doing. See each subfolder's README for caveats.
- bc-safety-stock — how much buffer to hold
- bc-eoq-calculator — how much to order
- bc-reorder-point — when to order
MIT — see LICENSE.
Grigorios Mavrogeorgis — Director and Founder of GMSOFT Limited Microsoft Dynamics 365 Business Central Community Super User, Season 1 2026 Blog: Inside Business Central