Skip to main content
Glama

Fit Features to Mesh

mesh_to_features
Read-only

Use this when you are handed an STL, OBJ or 3MF of a mostly prismatic mechanical part (plate, bracket, spacer, flange, housing block) and need an EDITABLE kernelCAD model of it rather than a faceted lib.fromSTL import. Deterministic, measured, self-verifying: it welds and checks the mesh, segments planes and cylinders, picks the extrusion axis, slices each band and fits exact lines / arcs / circles, snaps near-round values (each snap recorded), then emits a readable .kcad.ts with named param()s — a revolve for concentric round stacks, extruded profiles otherwise, .hole()/.holes() for through, blind and counterbored bores (axial and side-drilled), .cutout() for pockets, .fillet() for constant-radius edge blends (radius measured on the sharp edge, edges grouped by radius and picked with the shortest exact edge query), boolean subtractions for what no drilling feature can reach. It then EVALUATES that script and compares it with the mesh: volume IoU (column ray casting) and symmetric surface deviation (max + RMS), over up to 4 refinement passes. Returns { script, ledger, fidelity: { maxDeviationMm, rmsMm, volumeIoU, verdict: faithful | approximate | failed, thresholds }, unmatchedRegions, features, passes }. A fillet or sharp reading is kept by which measures better; variable-radius blends and chamfers are reported, not forced. The verdict is computed from the numbers — faithful needs IoU >= minIoU AND max deviation <= maxDeviationMm AND a watertight mesh AND no unmatched region. Freeform surfaces, tilted planes and side bosses are listed in unmatchedRegions (reference.mesh.freeform-region-unmatched), never silently dropped. The ledger uses fact ids equal to param names, so resolve_assumptions on the written .ledger.json yields paramOverrides for set_param. Pass { out } to write the script and ledger; the mesh itself is never modified. Hosted: give the file as an https:// URL, a data: URI (base64, max 25 MB) or "asset:" from request_upload (when the file is on the user's device).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
outNoWrite the emitted script to this .kcad.ts path and the assumption ledger to the sibling .ledger.json.
dataNoMesh bytes as base64 — use when the server cannot see your filesystem.
fileNoPath to a .stl (binary or ASCII), .obj or .3mf mesh. One of file / data is required. Hosted server: cannot read files from your machine — pass `code`, or `project:<slug>` for a saved project. Hosted server: pass an https:// URL, a data: URI, or "asset:<id>" from request_upload — not a path on your machine.
formatNoFormat override; default from the extension or the content.
minIoUNoVolume IoU a faithful verdict requires. Default 0.98.
maxPassesNoRefinement passes, 1–4. Default 4; stops early at the first faithful pass.
maxTrianglesNoRefuse meshes above this triangle count instead of stalling. Default 300000.
maxDeviationMmNoMax surface deviation (mm) a faithful verdict allows. Default max(0.25, 0.1 % of the bbox diagonal).
weldToleranceMmNoVertex weld distance in mm. Default max(1e-4, 1e-6 × bbox diagonal).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • removedOutput schema / properties
      Removed value: -{
      -  "diagnostics": {
      -    "items": {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  "error": {
      -    "description": "Failure message (failure).",
      -    "type": "string"
      -  },
      -  "errorCode": {
      -    "type": "string"
      -  },
      -  "features": {
      -    "additionalProperties": true,
      -    "description": "Body kind, hole groups, cutouts, boolean remainders, params (success).",
      -    "type": "object"
      -  },
      -  "fidelity": {
      -    "additionalProperties": true,
      -    "description": "Measured fidelity of the returned script (success).",
      -    "properties": {
      -      "maxDeviationMm": {
      -        "description": "Two-sided discrete Hausdorff distance, mesh vs reconstruction.",
      -        "type": "number"
      -      },
      -      "pass": {
      -        "description": "Refinement pass whose script is returned.",
      -        "type": "number"
      -      },
      -      "rmsMm": {
      -        "description": "RMS of the sampled point-to-surface distances.",
      -        "type": "number"
      -      },
      -      "thresholds": {
      -        "additionalProperties": true,
      -        "description": "{ minIoU, maxDeviationMm, approximateIoU } actually applied.",
      -        "type": "object"
      -      },
      -      "verdict": {
      -        "description": "faithful = IoU and deviation within thresholds, watertight mesh, nothing unmatched; approximate = IoU >= 0.85.",
      -        "enum": [
      -          "faithful",
      -          "approximate",
      -          "failed"
      -        ],
      -        "type": "string"
      -      },
      -      "volumeIoU": {
      -        "description": "Volume intersection-over-union by column ray casting.",
      -        "type": "number"
      -      }
      -    },
      -    "required": [
      -      "maxDeviationMm",
      -      "rmsMm",
      -      "volumeIoU",
      -      "verdict"
      -    ],
      -    "type": "object"
      -  },
      -  "ledger": {
      -    "additionalProperties": true,
      -    "description": "AssumptionLedger { facts, unresolvedCount }; dimension fact ids equal the param names (success).",
      -    "type": "object"
      -  },
      -  "mesh": {
      -    "additionalProperties": true,
      -    "description": "Clean-up and watertightness report for the input mesh.",
      -    "type": "object"
      -  },
      -  "notRepresented": {
      -    "items": {
      -      "type": "string"
      -    },
      -    "type": "array"
      -  },
      -  "ok": {
      -    "type": "boolean"
      -  },
      -  "passes": {
      -    "description": "Per-pass tolerances and measured fidelity.",
      -    "items": {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  "reconstructedHoles": {
      -    "description": "Holes the B-rep hole detector finds on the reconstruction.",
      -    "items": {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  "script": {
      -    "description": "The emitted, evaluable .kcad.ts source (success).",
      -    "type": "string"
      -  },
      -  "unmatchedRegions": {
      -    "description": "Surface regions no emitted feature represents: { kind, reason, areaMm2, triangleCount, centroid, bbox }.",
      -    "items": {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  "written": {
      -    "additionalProperties": true,
      -    "description": "{ script, ledger } paths when out was given.",
      -    "type": "object"
      -  }
      -}
    • removedOutput schema / required
      Removed value: -[
      -  "ok"
      -]
  2. Changed1 schema field changed
    • changedInput schema / properties / file / description
      Previous value: -"Path to a .stl (binary or ASCII), .obj or .3mf mesh. One of file / data is required. Hosted server: cannot read files from your machine — pass `code`, or `project:<slug>` for a saved project."New value: +"Path to a .stl (binary or ASCII), .obj or .3mf mesh. One of file / data is required. Hosted server: cannot read files from your machine — pass `code`, or `project:<slug>` for a saved project. Hosted server: pass an https:// URL, a data: URI, or \"asset:<id>\" from request_upload — not a path on your machine."
  3. Changed1 schema field changed
    • changedInput schema / properties / file / description
      Previous value: -"Path to a .stl (binary or ASCII), .obj or .3mf mesh. One of file / data is required."New value: +"Path to a .stl (binary or ASCII), .obj or .3mf mesh. One of file / data is required. Hosted server: cannot read files from your machine — pass `code`, or `project:<slug>` for a saved project."
  4. Added

TDQS

Score is being calculated.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.