Skip to main content
Glama

compile_scad

Compile OpenSCAD code or .scad files into STL, then validate the mesh and reject floating pieces or missing libraries before printing.

Instructions

Compile OpenSCAD code into an STL file.

        Takes OpenSCAD source code OR a path to a .scad file, compiles
        it using the local OpenSCAD binary, and returns the path to the
        generated STL. Kiln's bundled BOSL2 and MCAD libraries are on
        OpenSCAD's library path (``include <BOSL2/std.scad>``).

        For surface() heightmap operations (photo emboss, lithophane),
        increase timeout to 600+ seconds.

        Kiln checks the compiled part is joined up.  A piece that floats
        with nothing under it is joined to nothing and prints as a loose
        part on supports, or not at all, so the make is REFUSED
        (``code: "FLOATING_PIECES"``; ``error`` names the pieces, how
        far they are from the nearest surface, and the fix): correct
        the geometry and compile again.  Separate parts that all sit on
        the bed are a plate and pass; a piece held inside the part (a
        ball in a cage, a pin in its knuckles) passes with a warning; a
        piece that touches the rest without overlapping it is named in
        ``warnings``.

        A compile where OpenSCAD could not find an included library, an
        imported file or a module is refused too: OpenSCAD leaves that
        part out and still exits cleanly, so the file would be missing
        pieces.  ``error`` names what was missing.

        A setting the called module has no parameter for (OpenSCAD
        ignores it and builds the default size) is read by the module's
        own name when that is certain and a measured build confirms it:
        ``settings_read`` says what was read, once, and
        ``corrected_scad_code`` is the code built; keep that code.
        Otherwise the compile is refused and ``error`` lists the
        module's real settings.

        Colour: pass ``color`` (a name such as ``"teal"`` or a hex) when
        the user asked for one, and the preview and the 3D stage show
        the part in it.  Left out, a single ``color("...")`` in the
        source is used.  It is how the part is SHOWN; it prints in
        whatever filament is loaded, and the result's ``color`` block
        says so.

        Round shapes: leave ``$fn`` out and Kiln cuts each curve by its
        size, writing that rule into the file it compiles.  Set ``$fn``
        only for a deliberate polygon (``$fn = 6`` for a hexagon).  A
        file that sets ``$fn``, ``$fa`` or ``$fs`` at the top compiles
        exactly as written, and the result's ``curve_resolution`` note
        says so.

        Named parts: a source may define each part as its own module and
        compose them in ``module main()``, drawing nothing at the top
        level; it compiles to ``main()``.  Kiln keeps generated designs
        this way, so a kept source compiles as it is.

        When you pass ``fastener``, the result carries a
        ``fastener_advice`` block saying the code compiled as written
        and nothing resized the hole for that fastener.  Kiln raises
        it once per session across every tool that can raise it.  Read
        its ``agent_instruction`` before repeating any of it.

        Args:
            goal_id: The saved goal's id from ``design_session``, so this make
                is recorded against the goal and checked against it. Empty when
                there is no goal.
            scad_code: Valid OpenSCAD source code (provide this OR scad_path).
            scad_path: Path to a .scad file (provide this OR scad_code).
            timeout: Maximum compilation time in seconds (default 300).
            fastener: The fastener the user named, e.g. ``"M4"`` — pass
                only if they actually said one.  Kiln does NOT read your
                OpenSCAD looking for screw holes; guessing intent out of
                geometry would be wrong often. No argument, no advisory.
            color: The colour the user asked for, shown on the preview and
                the stage (a name or ``#rrggbb``).  Not a print setting.
            motion: When the part has pieces that move against each other (a
                hinge, a gearbox, a slider): how it moves, in your source's own
                part names, so the reply's ``motion`` can say whether it plays
                and what was found.  ``{"parts": {name: [x, y, z]}}`` gives each
                piece a point inside its material (millimetres, as modelled);
                ``"joints"`` lists ``{"parts": [stays, moves], "kind": "hinge" |
                "slider" | "fixed", "axis_point", "axis_direction", and
                "range": [lo, hi] or "continuous": true}``; ``"driver"`` names
                the piece a hand turns or slides (leave it out when each piece
                moves on its own, like drawers in a case); ``"gears"`` (optional) lists
                ``{"parts": [a, b], "teeth": [na, nb], "carrier": the piece
                holding both axes, "inside": true when b is a ring with its
                teeth inside}``.  Checked with a goal (``goal_id``) on a make
                Kiln's servers answer; then the stage on this computer plays it
                too.  Elsewhere the reply carries no ``motion``.

INLINE 3D STAGE: on success this tool opens Kiln's interactive 3D stage — an inline viewer panel the user can orbit, zoom, and turn over — in hosts that render MCP Apps panels (Kiln's hosted connection attaches a browser stage link for hosts that don't). Oversized meshes are decimated automatically for the stage; the PNG preview is the floor, not the whole experience.

MAKE DOORS: design_session, Kiln's front door for making an object, is not installed here (signed in to Kiln it runs on Kiln's servers). On this install compile_scad IS the make → preview → iterate loop: make it, show the preview, iterate.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "compile_scad"
  }
}

Input Schema

NameRequiredDescriptionDefault
colorNoThe colour the user asked for, shown on the preview and the stage (a name or ``#rrggbb``). Not a print setting. Default: "".
motionNoWhen the part has pieces that move against each other (a hinge, a gearbox, a slider): how it moves, in your source's own part names, so the reply's ``motion`` can say whether it plays and what was found. ``{"parts": {name: [x, y, z]}}`` gives each piece a point inside its material (millimetres, as modelled); ``"joints"`` lists ``{"parts": [stays, moves], "kind": "hinge" | "slider" | "fixed", "axis_point", "axis_direction", and "range": [lo, hi] or "continuous": true}``; ``"driver"`` names the piece a hand turns or slides (leave it out when each piece moves on its own, like drawers in a case); ``"gears"`` (optional) lists ``{"parts": [a, b], "teeth": [na, nb], "carrier": the piece holding both axes, "inside": true when b is a ring with its teeth inside}``. Checked with a goal (``goal_id``) on a make Kiln's servers answer; then the stage on this computer plays it too. Elsewhere the reply carries no ``motion``.
goal_idNoThe saved goal's id from ``design_session``, so this make is recorded against the goal and checked against it. Empty when there is no goal. Default: "".
timeoutNoMaximum compilation time in seconds (default 300). Default: 300.
fastenerNoThe fastener the user named, e.g. ``"M4"`` — pass only if they actually said one. Kiln does NOT read your OpenSCAD looking for screw holes; guessing intent out of geometry would be wrong often. No argument, no advisory. Default: "".
scad_codeNoValid OpenSCAD source code (provide this OR scad_path). Default: "".
scad_pathNoPath to a .scad file (provide this OR scad_code). Default: "".

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.6.0
    • removedInput schema / properties / brief_id
      Removed value: -{
      -  "description": "The saved goal's id from ``design_session``, so this make is recorded against the goal and checked against it. Empty when there is no goal. Default: \"\".",
      -  "title": "Brief Id",
      -  "type": "string"
      -}
    • addedInput schema / properties / goal_id
      Added value: +{
      +  "description": "The saved goal's id from ``design_session``, so this make is recorded against the goal and checked against it. Empty when there is no goal. Default: \"\".",
      +  "title": "Goal Id",
      +  "type": "string"
      +}
    • addedInput schema / properties / motion
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": true,
      +      "type": "object"
      +    },
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "When the part has pieces that move against each other (a hinge, a gearbox, a slider): how it moves, in your source's own part names, so the reply's ``motion`` can say whether it plays and what was found.  ``{\"parts\": {name: [x, y, z]}}`` gives each piece a point inside its material (millimetres, as modelled); ``\"joints\"`` lists ``{\"parts\": [stays, moves], \"kind\": \"hinge\" | \"slider\" | \"fixed\", \"axis_point\", \"axis_direction\", and \"range\": [lo, hi] or \"continuous\": true}``; ``\"driver\"`` names the piece a hand turns or slides (leave it out when each piece moves on its own, like drawers in a case); ``\"gears\"`` (optional) lists ``{\"parts\": [a, b], \"teeth\": [na, nb], \"carrier\": the piece holding both axes, \"inside\": true when b is a ring with its teeth inside}``.  Checked with a goal (``goal_id``) on a make Kiln's servers answer; then the stage on this computer plays it too.  Elsewhere the reply carries no ``motion``.",
      +  "title": "Motion"
      +}
  2. Changed6 schema fields changedv1.5.1
    • changedInput schema / properties / brief_id / description
      Previous value: -"Default: \"\"."New value: +"The saved goal's id from ``design_session``, so this make is recorded against the goal and checked against it. Empty when there is no goal. Default: \"\"."
    • changedInput schema / properties / color / description
      Previous value: -"Default: \"\"."New value: +"The colour the user asked for, shown on the preview and the stage (a name or ``#rrggbb``).  Not a print setting. Default: \"\"."
    • changedInput schema / properties / fastener / description
      Previous value: -"Default: \"\"."New value: +"The fastener the user named, e.g. ``\"M4\"`` — pass only if they actually said one.  Kiln does NOT read your OpenSCAD looking for screw holes; guessing intent out of geometry would be wrong often. No argument, no advisory. Default: \"\"."
    • changedInput schema / properties / scad_code / description
      Previous value: -"Default: \"\"."New value: +"Valid OpenSCAD source code (provide this OR scad_path). Default: \"\"."
    • changedInput schema / properties / scad_path / description
      Previous value: -"Default: \"\"."New value: +"Path to a .scad file (provide this OR scad_code). Default: \"\"."
    • changedInput schema / properties / timeout / description
      Previous value: -"Default: 300."New value: +"Maximum compilation time in seconds (default 300). Default: 300."
  3. Changed9 schema fields changedv1.5.0
    • addedInput schema / properties / brief_id
      Added value: +{
      +  "description": "Default: \"\".",
      +  "title": "Brief Id",
      +  "type": "string"
      +}
    • addedInput schema / properties / color
      Added value: +{
      +  "description": "Default: \"\".",
      +  "title": "Color",
      +  "type": "string"
      +}
    • addedInput schema / properties / fastener
      Added value: +{
      +  "description": "Default: \"\".",
      +  "title": "Fastener",
      +  "type": "string"
      +}
    • removedInput schema / properties / scad_code / default
      Removed value: -""
    • addedInput schema / properties / scad_code / description
      Added value: +"Default: \"\"."
    • removedInput schema / properties / scad_path / default
      Removed value: -""
    • addedInput schema / properties / scad_path / description
      Added value: +"Default: \"\"."
    • removedInput schema / properties / timeout / default
      Removed value: -300
    • addedInput schema / properties / timeout / description
      Added value: +"Default: 300."
  4. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare readOnlyHint=false, destructiveHint=false, openWorldHint=false; the description goes far beyond that with refusal semantics that matter for invocation: floating-piece makes are REFUSED with code FLOATING_PIECES, missing includes/imports are refused rather than silently dropped, and settings a module lacks a parameter for trigger either settings_read/corrected_scad_code or a refusal. It also discloses side effects (inline 3D stage opens, mesh decimation, fastener_advice raised once per session) and the pending-motion limitation when no goal/servers are present.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The core purpose is front-loaded in sentence one, and the failure-mode paragraphs carry genuinely useful information. However, the description runs to roughly a dozen paragraphs, duplicates schema parameter text nearly word-for-word in the Args section, and buries the actionable $fn and timeout rules mid-body. Several sentences (named parts/main(), the colour-is-for-display aside) are restated more than once.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With seven optional parameters, no output schema, and a complex refusal/validation pipeline, the description carries the full burden and does so: it names the fields an agent will need to read back (error, warnings, settings_read, corrected_scad_code, curve_resolution, color, motion, fastener_advice), explains each refusal condition, and states what happens in hosts without MCP Apps panels. Nothing an agent needs to call this correctly appears to be missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds real meaning beyond the schema: the timeout guidance of 600+ seconds for surface() heightmaps is not in the schema, and it clarifies intent constraints ('pass only if they actually said one') and what each field buys in the reply (settings_read, corrected_scad_code, color block, motion results). Much of the color/motion/fastener text is repeated verbatim from the schema, which caps the score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb and resource: 'Compile OpenSCAD code into an STL file', then immediately clarifies the dual input mode (source code OR a .scad path) and the toolchain (local OpenSCAD binary, BOSL2/MCAD on the library path). The closing 'MAKE DOORS' paragraph explicitly positions it against its sibling design_session, so an agent knows this is the make/preview/iterate entry point on this install.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete when-to guidance: raise timeout to 600+ for surface() heightmaps, pass fastener only if the user actually named one, pass color only when requested, pass motion only when parts move, and set $fn only for deliberate polygons. It also routes away from design_session when that sibling is unavailable. It does not address when to prefer siblings like tweak_and_compile_scad or analyze_scad_code, so it stops short of full exclusion guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools