Tutorial 7 of 7
Automate Kerfwise with the API and MCP
Advanced 15 min
Call the Kerfwise engine from scripts and AI agents — cabinet builder, cut list and sheet nesting as JSON API and MCP tools, with real request and response examples.
The workspace and the API run the same engine code. Three tools are available on every usefulweb.site host as JSON API (POST /api/v1/tools/<id>/calculate), in the OpenAPI document and as MCP tools (POST /mcp, tool names with underscores).
| Tool id | MCP name | What it does |
|---|---|---|
kerfwise-cabinet-builder | kerfwise_cabinet_builder | parameters → parts, cut sizes, drilling counts, hardware, front/side SVG, DXF, project JSON |
kerfwise-cut-list | kerfwise_cut_list | cabinets or a project → grouped cut list, banding, hardware, sheets per material, cost estimate, CSV |
kerfwise-sheet-nesting | kerfwise_sheet_nesting | parts + sheet + kerf → layouts, yield, offcuts, cut length, SVG + DXF |
All lengths are millimetres. The examples below were run against the real server; numbers are copied from the responses.
1. Nest parts on a sheet
POST /api/v1/tools/kerfwise-sheet-nesting/calculate
Content-Type: application/json
{"parts":[{"name":"Side","length":720,"width":559,"qty":4,"grain":true},
{"name":"Shelf","length":562,"width":515,"qty":4,"grain":true}],
"sheetLength":2800,"sheetWidth":2070,"kerf":4,"trim":10,
"method":"guillotine","grainedMaterial":true,"sheetPrice":148}
Response (abridged):
{
"summary": "8 of 8 parts fit on 1 sheet of 2800 × 2070 mm with 47.8 % yield (guillotine).",
"result": {
"method": "guillotine",
"strategy": "guillotine BSSF/LLAS, sorted by area",
"sheetCount": 1,
"yieldPct": 47.8,
"offcutAreaM2": 2.75,
"cutLengthM": 22.2,
"cost": 148,
"sheets": [{
"index": 1,
"placements": [
{"name": "Side", "label": "1.1", "x": 10, "y": 10, "w": 720, "h": 559, "rotated": false},
{"name": "Side", "label": "1.2", "x": 734, "y": 10, "w": 720, "h": 559, "rotated": false}
],
"offcuts": [{"x": 10, "y": 1136, "w": 2780, "h": 924}, {"x": 2432, "y": 573, "w": 358, "h": 519}]
}]
}
}
Note the kerf: the second side starts at x = 10 + 720 + 4 = 734. The presentation part of the response also contains the SVG of every sheet and a DXF download.
2. Build a cabinet
POST /api/v1/tools/kerfwise-cabinet-builder/calculate
Content-Type: application/json
{"type":"base","width":600,"height":870,"depth":560,"backType":"groove","grooveDepth":8,
"plinthType":"legs","plinthHeight":150,"doorCount":1,"shelfCount":1,"topType":"rails"}
{
"summary": "Base cabinet 600 × 870 × 560 mm: 9 parts, 47 hardware items, 2 hinges per door, side height 720 mm.",
"result": {
"dimensions": {"sideHeight": 720, "innerWidth": 564, "innerDepth": 536, "backSize": "710 × 580", "doorSize": "717 × 597", "hingesPerDoor": 2},
"parts": [
{"label": "A7", "name": "Back panel (grooved)", "L": 710, "W": 580, "T": 8, "cutL": 710, "cutW": 580, "material": "HDF 8 mm (backs, grooved)"}
],
"totals": {"parts": 9, "holes": 112, "areaM2": 2.45, "bandingM": 6.4},
"openInApp": "https://kerfwise.usefulweb.site/app#project=eyJmb3…"
}
}
openInApp opens the cabinet in the workspace; project contains the same project as JSON.
3. Cut list and cost for several cabinets
POST /api/v1/tools/kerfwise-cut-list/calculate
Content-Type: application/json
{"cabinets":[{"type":"base","width":600,"doors":1,"shelves":1},
{"type":"drawer","width":600,"drawers":3},
{"type":"wall","width":800,"doors":2}],
"currency":"EUR","labourRate":45}
{
"summary": "Cut list: 44 parts in 19 cut-list rows on 4 sheets (yield 44.1 %), 26 m edge banding — estimated total 868.78 EUR.",
"result": {
"cost": {"materials": 499, "banding": 19.05, "hardware": 164.2, "labour": 186.53, "labourMinutes": 248.7, "subtotal": 868.78, "total": 868.78, "currency": "EUR"},
"totals": {"cabinets": 3, "partRows": 19, "pieces": 44, "holes": 266, "sheets": 4, "sheetYieldPct": 44.1, "bandingM": 26}
}
}
Instead of the cabinets table you can pass a whole project as a string in project (a .kerfwise.json file — the schema is published on the Kerfwise landing page and in the OpenAPI document). Settings inside the project (kerf, prices, labour) win over the form fields.
4. The same via MCP
{"jsonrpc":"2.0","id":1,"method":"tools/call",
"params":{"name":"kerfwise_sheet_nesting",
"arguments":{"parts":[{"name":"Panel","length":600,"width":500,"qty":16}],
"sheetLength":2800,"sheetWidth":2070,"kerf":4,"trim":10,"method":"guillotine","grainedMaterial":false}}}
The text content of the answer starts with 16 of 16 parts fit on 1 sheet of 2800 × 2070 mm with 82.8 % yield (guillotine). and structuredContent holds the same result object as the API.
5. Hand a project to a human
Build a project JSON (see the project schema), base64url-encode it and append it to the app URL:
https://kerfwise.usefulweb.site/app#project=<base64url of the JSON>
The fragment never reaches the server; the app decodes it, opens the project and removes it from the address bar.