compose_part_from_primitives
Build exact, functional 3D parts by combining geometric primitives with boolean union, difference, and intersection operations, then export a print-ready STL centered on the bed.
Instructions
Build a functional part by composing geometric primitives with booleans.
The **CAD-aware generation path** -- instead of asking text-to-mesh AI
to guess at geometry, describe parts as a tree of primitives combined
with boolean operations. Produces exact, deterministic, functional parts.
**SAFETY DEFAULT (changed 2026-04-15):** ``center_on_bed=True`` is the
default. OpenSCAD primitives are natively centered on the model origin
(``cylinder(h,r)`` produces geometry centered on X/Y = (0,0), which
means half the geometry lives at NEGATIVE X/Y). Sending such an STL
to most FDM printers (Bambu, Prusa, Ender, Creality) — whose bed
origin is the front-left corner — causes the nozzle to drive off-bed
into the purge/wipe assembly on layer 1. This happened once on a
Bambu A1 (incident #0, 2026-04-15, nearly damaged the printer).
With ``center_on_bed=True`` the output STL is translated so it sits
centered on the build plate and its lowest point touches z=0. Set
``center_on_bed=False`` only if your downstream flow expects
origin-centered geometry (e.g. further CAD composition).
**Operation format** -- each item is either a primitive or boolean:
Primitive: ``{"type": "primitive", "shape": "<shape>",
"params": {...}, "translate": [x,y,z], "rotate": [rx,ry,rz]}``
Boolean: ``{"type": "boolean", "operation": "union|difference|intersection",
"children": [op1, op2, ...]}``
**Primitive shapes and params:**
- cube: ``{"size": [x,y,z]}`` or ``{"size": scalar}``
- cylinder: ``{"h": height, "r": radius}`` or ``{"h", "r1", "r2"}``
- sphere: ``{"r": radius}``
- cone: ``{"h": height, "r1": bottom_r, "r2": top_r}``
- torus: ``{"major_r": ring_radius, "minor_r": tube_radius}``
- wedge: ``{"width": w, "depth": d, "height": h}``
- hex_prism: ``{"r": radius, "h": height}`` -- hexagonal (for nuts)
- text: ``{"text": "string", "size": 10, "depth": 2}``
- rounded_cube: ``{"size": [x,y,z], "radius": 1}``
- pipe: ``{"h": height, "outer_r": 10, "inner_r": 8}``
Requires OpenSCAD installed on the system.
:param brief_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.
:param operations: The part as a tree of operation dicts. A
primitive is ``{"type": "primitive", "shape": ..., "params": {...}}``
with optional ``"translate": [x,y,z]`` and ``"rotate": [rx,ry,rz]``;
shape is one of ``cube``, ``cylinder``, ``sphere``, ``cone``,
``torus``, ``wedge``, ``hex_prism``, ``text``, ``rounded_cube``,
``pipe``. A boolean is ``{"type": "boolean", "children": [...]}``
with ``"operation"`` ``union``, ``difference`` or ``intersection``.
Shape params are listed in the tool description.
:param output_path: Output path (defaults to temp file).
:param center_on_bed: Translate output to bed-center (default True).
:param bed_x_mm: Build plate X dimension for centering (default 256).
:param bed_y_mm: Build plate Y dimension for centering (default 256).
:param printer_id: Optional printer: a supported model id, or the
name of a printer set up in Kiln. When provided, its recorded
bed size replaces the explicit dimensions.
:returns: Dict with result path, SCAD code, triangle count, and
(if centered) ``bed_centered=True`` + applied translation.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
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"operations": "<operations>"
},
"name": "compose_part_from_primitives"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bed_x_mm | No | Build plate X dimension for centering (default 256). Default: 256.0. | |
| bed_y_mm | No | Build plate Y dimension for centering (default 256). Default: 256.0. | |
| brief_id | No | 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: "". | |
| operations | Yes | The part as a tree of operation dicts. A primitive is ``{"type": "primitive", "shape": ..., "params": {...}}`` with optional ``"translate": [x,y,z]`` and ``"rotate": [rx,ry,rz]``; shape is one of ``cube``, ``cylinder``, ``sphere``, ``cone``, ``torus``, ``wedge``, ``hex_prism``, ``text``, ``rounded_cube``, ``pipe``. A boolean is ``{"type": "boolean", "children": [...]}`` with ``"operation"`` ``union``, ``difference`` or ``intersection``. Shape params are listed in the tool description. | |
| printer_id | No | Optional printer: a supported model id, or the name of a printer set up in Kiln. When provided, its recorded bed size replaces the explicit dimensions. Default: "". | |
| output_path | No | Output path (defaults to temp file). Default: "". | |
| center_on_bed | No | Translate output to bed-center (default True). Default: true. |