repair_mesh
Repair STL mesh defects: weld coincident vertices, remove zero-area triangles, and optionally close holes via fan triangulation. Returns repair statistics and a residual defect report.
Instructions
Repair mesh defects: rounding-noise seams, degenerates, holes.
Every pass first welds vertices that are coincident up to a tiny
radius (0.1 µm by default) — scanned and AI-generated meshes
routinely carry float rounding jitter that reads as thousands of
phantom open edges, and welding is the honest fix for those. The
default pass then removes zero-area triangles and recomputes face
normals. Pass ``close_holes=True`` for the deep pass, which
additionally finds boundary edges (edges shared by only one
triangle) and closes small holes via fan triangulation — use it
when the mesh is not watertight.
Hole closing refuses rather than ruins: sewing triangles that
merely re-stamp existing surface are discarded, and a closure
that collapses the enclosed volume is rolled back with the
reason in ``unrepaired``.
The result states the output's actual condition: ``is_watertight``
(which also refuses to certify a sheet-cancelling zero-volume
surface), remaining boundary/pinch edge counts,
``enclosed_volume_mm3`` when the surface closes up, and — when
defects survive the pass — an ``unrepaired`` list saying which
defect classes this tool has no repair for (pinched edges, where
3+ triangles meet along one line, are not holes and cannot be
sewn; they must be fixed where the geometry was made). Read
``unrepaired`` before telling the user the mesh is fixed.
:param file_path: Path to the STL file to repair.
:param output_path: Output path. Defaults to overwriting the input.
:param close_holes: Also close open holes and fix boundary edges
(slower; default False).
:param weld_tolerance: Weld radius in mm. Empty = auto (0.1 µm or
a millionth of the part diagonal); "0" disables welding.
:returns: Dict with repair statistics and residual-defect report.INLINE 3D STAGE: on success this tool also 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.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| close_holes | No | ||
| output_path | No | ||
| weld_tolerance | No |