Render Preview
render_previewUse this when you need to LOOK at a kernelCAD model — render its script to deterministic PNG views for visual self-check (the visual half of the evaluate → render → inspect → fix loop), with NO studio or dev server required. Pass { code } (inline source) or { file } (a .kcad.ts path), exactly one. Renders the canonical engineering views (front, right, top, iso — pass { views } for a subset, e.g. ["iso"] for fastest iteration) plus an optional { pose: "," } arbitrary camera angle (degrees; az=0,el=0 is front, +az rotates CCW around +Z, +el lifts the camera). NO STUDIO / DEV-SERVER REQUIRED: a prebuilt static player (dist/headless-player) is served from an ephemeral local port automatically; a running studio dev server is used as fallback, and { base_url } forces one. The only environment dependency is playwright chromium (npx playwright install chromium). Pass { focus } or { hide } (arrays of feature ids or assembly part names, mutually exclusive) to isolate parts — same semantics as kernelcad render --focus/--hide. PNGs are written to { out_dir } (default: a fresh temp session directory) and returned as absolute paths with per-view camera descriptions (kernelCAD is Z-up). Mechanism truth runs first, same protocol as kernelcad render: a broken mechanism still renders but every tile is watermarked MECHANISM BROKEN (KERNELCAD_RENDER_STRICT=1 refuses instead); read { mechanism, mechanism_failure_codes }. The probe runs full BREP interference sweeps and can dominate latency on large assemblies — pass { no_mechanism_check: true } for fast iteration (the preview then reports mechanism: "unverified"; ignored under strict mode). Returns { ok, images: [{ name, path, description }], out_dir, bounds, mechanism, render_source, render_ms, diagnostics }. PATHS ARE LOCAL to the machine running the MCP server — local stdio clients read them directly; hosted/remote clients should use open_in_studio instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Inline kernelCAD script source. Mutually exclusive with file. Relative imports resolve against a temp dir — use file for scripts with relative lib.fromSTEP(...) imports. | |
| file | No | Path to a .kcad.ts script on disk. Mutually exclusive with code. | |
| hide | No | Hide matching feature ids / assembly part names. Mutually exclusive with focus. | |
| pose | No | Extra arbitrary camera pose '<az>,<el>' in degrees, e.g. '30,20'. | |
| focus | No | Show only matching feature ids / assembly part names. Mutually exclusive with hide. | |
| views | No | Canonical views to render as an array, e.g. ["iso"] or ["front","top"] (default: all four). Fewer views = faster. | |
| width | No | Per-view tile width in px (default 768). | |
| height | No | Per-view tile height in px (default 768). | |
| out_dir | No | Directory for the PNGs (created if missing). Default: a fresh temp session dir. | |
| base_url | No | Advanced: force a specific render server (e.g. a running studio dev server) instead of the bundled static player. | |
| environment | No | HDRI environment override: preset ('studio', 'softbox', 'neutral', 'outdoor', 'warehouse'), a URL, or 'none' for the default three-light rig. | |
| no_watermark | No | Suppress the kernelCAD version watermark. | |
| no_mechanism_check | No | Skip the mechanism-truth probe for fast iteration on large assemblies; the preview reports mechanism: 'unverified'. Ignored under KERNELCAD_RENDER_STRICT=1. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Whether the preview rendered. | |
| error | No | ||
| bounds | No | Model AABB in mm { min, max } the camera was fit to (success). | |
| images | Yes | Rendered tiles { name, path, description } — absolute local PNG paths with per-view camera orientation (kernelCAD is Z-up). | |
| out_dir | No | Directory holding the PNGs (session temp dir unless out_dir was given). | |
| errorCode | No | ||
| errorHint | No | ||
| mechanism | No | Mechanism-truth verdict: 'real' | 'broken' | 'unverified'. | |
| render_ms | No | Wall-clock render time in ms (provisioning + browser + captures). | |
| diagnostics | Yes | ||
| render_source | No | Lane that served the render: 'static-player' | 'dev-server' | 'explicit'. | |
| mechanism_failure_codes | No | De-duplicated failure codes when mechanism is 'broken'. |