Skip to content

About

est lab for ClassCAD, a headless CAD engine, driven by AI agents (Claude Code + MCP): Node harness, 13 verified parametric cases (generic and aerospace), exact prompts and iteration logs.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ClassCAD AI lab

Versione italiana

A test lab for ClassCAD, the headless, programmable CAD engine by AWV Informatik (exact NURBS B-rep geometry, no user interface), driven by AI agents.

ClassCAD does not take natural-language requests: it executes code. In this lab an AI agent (Claude, in Claude Code) writes JavaScript programs against the ClassCAD API, the ClassCAD engine runs them locally, and the agent checks the result with numbers (volume, bounding box, positions) and renders before handing over STEP/STL files.

The repository contains:

  • MCP setup so that Claude Code can drive the ClassCAD engine through the official @classcad/mcp server;
  • run-and-check scripts (Node.js, in harness/) that have the ClassCAD engine build each test case, check its volume against an independent calculation and exports STEP, STL, GLB, OFB and PNG drawings;
  • 13 parametric test cases, generic (plate, flange, bracket, hinge assembly, constrained sketch) and aerospace (NACA airfoils, swept/dihedral/tapered/twisted wings, fuselage, wing box), each built and adversarially reviewed by AI agents;
  • the full record of how it was built: exact prompts, agent workflows, iteration histories with raw first drafts, and a "clean agent" experiment.

Related sites: classcad.ch (engine, keys, API docs) · classcad.ai (AI agents and MCP) · buerligons.io (browser CAD built on the same engine; opens the .stp and .ofb files produced here).

Tested on Windows 11 with Node 24, ClassCAD engine 21.2.0 and @classcad/mcp 0.2.1 (October 2026). Code comments in cases/ and CLAUDE.md are in Italian.


1. Setup

Requirements: Node ≥ 20.12 and a free account on classcad.ch.

npm install

npm may warn about allow-scripts for sharp and report 3 high-severity audit findings in sharp/libvips (dependencies of the ClassCAD packages, no fix available). They are harmless for local use; do not run npm audit fix --force.

Sign in for the agent (once per machine). It opens classcad.ch in the browser and stores the session in ~/.classcad-mcp/auth.json:

npm run mcp:login

For the direct mode you also need your own WASM key from classcad.ch/user: App Type wasm, Allowed Origins http://localhost:3000. Copy .env.example to .env and paste the key there. .env is git-ignored: never commit it.

The ClassCAD WASM engine 21.2.0 (about 89 MB) is downloaded on first use into ~/.classcad-mcp/wasm/21.2.0 and then works offline.

Adjust .mcp.json: it contains absolute paths (C:/dev/classcad/...). Replace them with the path of your clone, then open the folder in Claude Code and approve the classcad server with /mcp.

2. Using it with an AI agent (Claude Code)

Open the folder in Claude Code (desktop app or CLI); /mcp should show classcad connected. The agent also reads:

Example prompts:

  • "Build a Ø120 flange, 15 thick, with a Ø60 hub 25 high, a Ø40 through bore and 6 Ø11 holes on a Ø90 pitch circle. Check the volume, save STEP and STL in out/flange and show me the drawing."
  • "NACA 4415 airfoil, chord 800: extrude a 2.5 m wing panel and export the STEP."
  • "Run cases/12-wing-swept-dihedral.js with sweepDeg=30 and dihedralDeg=7 and show me the four views."

While working, the MCP server opens a live 3D view in the browser (http://127.0.0.1:9098/v/…) that follows every change and can export STEP, STL and glTF.

3. Using it from scripts (run-and-check scripts)

The run-and-check scripts take a case file, have the ClassCAD engine build it, export files and renders, and check the volume, without an AI agent. They reach the engine in two ways:

  • MCP mode: through the ClassCAD MCP server, exactly like an agent (needs the classcad.ch sign-in);
  • direct mode: the script loads the ClassCAD WASM engine in its own process (needs your WASM key; more export options, can run cases in parallel).

Both run on your PC and give identical results.

node harness/run-direct.mjs cases/00-smoke-box.js
node harness/run-direct.mjs cases/10-naca-polyline.js --param naca=4415 --param chord=800
node harness/run-all.mjs --no-render
Command What it does
node harness/run-direct.mjs <case> [--param k=v] [--no-render] [--no-export] [--stl-tol 0.01] [--stp-version 1|2|3] [--stp-analytic] Direct mode: ClassCAD engine in-process (WASM), no daemon, no sign-in; needs CLASSCAD_WASM_KEY. Starts in about 3 s. STEP 1 = AP203, 2 = AP214 (default), 3 = AP242; --stp-analytic writes planes, cylinders, lines and circles as analytic entities.
node harness/run-mcp.mjs <case> MCP mode: the same case through the official MCP server, i.e. exactly the tools an agent uses; needs the sign-in. Output in out/<case>@mcp/.
node harness/run-all.mjs [--mode mcp|direct] [--filter 1] [--no-render] All cases; summary in out/summary.json.
node harness/import-step.mjs file.stp Imports a STEP file (e.g. a loft made in OpenVSP, CadQuery or FreeCAD), checks it, exports and renders it.
node harness/probe-methods.mjs [v1.x.y …] Asks the ClassCAD engine itself (not the docs) whether a method exists.
npm run mcp:status / npm run mcp:stop Status and shutdown of the MCP daemon (-- --force to stop it while a session is open).

Each run writes to out/<case>/: .stp, .stl, .glb, .ofb, three PNG renders (iso, 4-view sheet, first-angle drawing), result.json (volume, expected value, relative error, logs) and script.js (the exact program that ran, which can be pasted into the agent's run_script tool).

Writing a case. A case is the body of an async function with api available. The run-and-check scripts prepend const P = {…} (parameters from cases/<name>.params.json plus --param overrides) and the helpers in cases/_prelude/ (nacaOutline, nacaSurfaces, placeSection, bezierChain, sampleBezier, bezierArea, polyArea, polyCentroid, DEG). It must end with return { volume, expected, tol }, where volume comes from part.calculateMassProperties and expected from the design math; the case fails if the relative error exceeds tol.

API documentation: node_modules/@classcad/skill/references/<domain>/<method>.md and recipes/*.md, or the MCP tools docs, list_methods, describe_method.

4. Test cases

Every case was built against the real ClassCAD engine by a builder agent and then reviewed by a second agent that recomputed the expected value independently, checked the renders, tried parameter variants and ran the case through the MCP as well (identical volumes in MCP and direct mode).

Generic cases

Case What it builds ClassCAD techniques Volume error
00-smoke-box 60×40×30 box part.box 0
01-plate-holes 120×80×10 plate, 4 corner holes Ø10, central hole Ø30 workCSys, cylinder, 2×2 linearPattern, boolean subtraction, B-rep probes 7e-6
02-flange Ø120 flange, Ø60 hub, Ø40 bore, 6 holes Ø11 on Ø90 merged circularPattern + one subtraction 1.4e-4
03-bracket-fillets L-bracket, concave R6 and convex R4 fillets, 2 holes edge selection by midpoint, fillet, parameter validity checks 4e-6
04-hinge-assembly Two-part hinge assembly rotated to 60° partTemplate, instance, revolute, motion checked through the centre of mass 0
05-parametric-sketch Plate from a fully constrained sketch driven by expressions, regenerated with new values sketch.* constraints and '@expr.W' dimensions, updateExpression 3e-5

Aerospace cases (aircraft axes: x aft, y spanwise, z up)

Case What it builds ClassCAD techniques Volume error
10-naca-polyline NACA 2412 wing panel, c = 1000, b = 3000 (121-point polygon) curve.polyline2d, solid.extrusion 2e-16
11-naca-bezier Same panel with a smooth profile: 40 cubic Bézier spans, true B-spline faces in the STEP batched curve.bezierCurve; max deviation 0.17 mm, but LE radius −33% at the default n = 20 (−8% at n = 60) 9e-10
12-wing-swept-dihedral Constant-chord half wing, 25° sweep, 5° dihedral oblique extrusion + rigid rotation 5e-13
13-wing-tapered Trapezoidal half wing, λ = 0.4, 20° LE sweep: exact loft as a frustum box cut by 121 solid.slice planes (convex profiles); fallback: 20 slabs 4e-14
14-fuselage-revolve 12 m fuselage (elliptic nose, cylinder, parabolic tail cone) solid.revolve, Pappus check 4e-5
15-wing-box Wing box: 5 ribs with 3 lightening holes each, spars at 25% and 65% chord clipped to the profile solid.copy, intersection, union, subtraction; Sutherland–Hodgman clipping 1e-4
16-wing-washout Half wing with −3° linear washout about the quarter chord part.twist (CUSTOM) on a segment sketch 1e-13

Residual errors on curved bodies come from the numerical integration in calculateMassProperties (about −2.5e-5 on bodies of revolution, up to ~1e-3 of a hole's volume); the geometry itself is exact, as confirmed by STL meshes and vertex positions.

5. ClassCAD for aerospace: what is there and what is missing (engine 21.2.0)

Verified by querying the ClassCAD engine: no loft, sweep, shell or thicken. Available: 2D polylines, arcs, ellipses, Bézier and interpolation curves, extrusion along any direction, revolve, part.twist, booleans, slice, section, offset, STEP import, mass properties.

Goal How it is done here
Airfoil section Closed polyline (exact volume) or G1 chain of cubic Béziers (true B-spline faces)
Sweep Oblique extrusion along [b·tanΛ, 0, b], sections stay streamwise
Dihedral Rigid rotation about the root chord
Washout part.twist with a custom axis at the quarter chord
Taper without twist Exact frustum for convex profiles (case 13); otherwise stacked slabs with known error
General loft Made elsewhere (OpenVSP, CadQuery, FreeCAD), imported as STEP with import-step.mjs (the reader honours the declared unit)
Fuselage, nacelles solid.revolve of a half profile
Structures Ribs with lightening holes, spars clipped to the profile, booleans

6. Licensing and privacy

  • This repository: MIT (see LICENSE). It does not include ClassCAD itself, which is proprietary software by AWV Informatik and is installed from npm; using it requires your own classcad.ch account and key.
  • ClassCAD plans (classcad.ch/subscriptions, checked October 2026): Free (non-commercial, MCP and scripting, STL export); Solo CHF 100/year (commercial, STEP and OFB export); Pro CHF 1,000/year per seat; Business CHF 5,000/year; individual contracts, including education. New accounts start with two weeks of Solo.
  • @classcad/mcp 0.2.1 works locally: CAD models do not leave the machine. It goes online only for the sign-in and the one-time engine download. The version is pinned; its built-in WASM key expires on 30 March 2027.
  • The ClassCAD skill in .claude/skills/classcad/ comes from awv-informatik/classcad-ai under its MIT license.

7. Known issues

  • "Ghost" geometry in renders after a parametric change (MCP 0.2.1): after part.updateExpression the client keeps old tessellations. Volume, STEP, STL and OFB are correct. With the agent: checkpoint then restore before snapshot; the run-and-check scripts do it automatically.
  • Request timeouts: a single ClassCAD engine call is limited to 30 s through the MCP and 120 s in direct mode; very large booleans must be split.
  • curve.interpolationCurve with 19 or more points crashes the ClassCAD WASM engine; use 4-point Bézier spans.
  • The MCP daemon uses ports 9096–9098 on 127.0.0.1; MCP mode in the run-and-check scripts uses a separate daemon on 9197.

8. How this project was built

The lab was set up by Claude Opus 5.5 (Claude Code) on request of the repository owner, using Claude sub-agents for research, case building, adversarial review and documentation. The process is documented in docs/processo/ (folder names and some documents are in Italian):

  • prompt-esatti.md: every prompt, verbatim (user messages, sub-agent prompts, demo script, clean-agent prompts);
  • workflow/: the scripts of the four agent workflows (research, case building, document review, iteration histories);
  • iterazioni/: for 8 cases, the builder's raw first draft with its renders and the sequence of attempts up to the final result;
  • clean-agent-experiment/: a fresh Claude Code session with only the MCP server and no project context, given a vague prompt (P1), a follow-up correction (P2) and an engineer-style specification (P3): scripts, images and final answers.

License

MIT © 2026 Francesco Perrelli

About

est lab for ClassCAD, a headless CAD engine, driven by AI agents (Claude Code + MCP): Node harness, 13 verified parametric cases (generic and aerospace), exact prompts and iteration logs.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages