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 — or a STEP file whose solid you need as an editable feature tree rather than a dumb lib.fromSTEP body (one solid; pass solid for a multi-solid file; the exact B-rep is tessellated finely and source reports the deflection the fidelity is measured to). 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 >= min_iou AND max deviation <= max_deviation_mm 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).

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": "mesh_to_features"
  }
}

Input Schema

NameRequiredDescriptionDefault
outNoWrite the emitted script to this .kcad.ts path and the assumption ledger to the sibling .ledger.json.
dataNoMesh or STEP bytes as base64 — use when the server cannot see your filesystem.
fileNoPath to a .stl (binary or ASCII), .obj or .3mf mesh, or a .step/.stp file. One of file / data is required. Hosted: `code`, `project:<slug>` (head), or a Studio `/p/<slug>?version=N` link (pinned); no local files. Hosted server: pass an https:// URL, a data: URI, or "asset:<id>" from request_upload — not a path on your machine.
solidNoSTEP only: 0-based solid to rebuild when the file holds more than one (inspect with of: "step" lists them). A multi-solid STEP without it is refused.
formatNoFormat override; default from the extension or the content (an ISO-10303-21 header is STEP).
min_iouNoVolume IoU a faithful verdict requires. Default 0.98.
max_passesNoRefinement passes, 1–4. Default 4; stops early at the first faithful pass.
max_trianglesNoRefuse meshes above this triangle count instead of stalling. Default 300000.
max_deviation_mmNoMax surface deviation (mm) a faithful verdict allows. Default max(0.25, 0.1 % of the bbox diagonal).
weld_tolerance_mmNoVertex weld distance in mm. Default max(1e-4, 1e-6 × bbox diagonal).

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / file / description
      Previous value: -"Path to a .stl (binary or ASCII), .obj or .3mf mesh, or a .step/.stp file. 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."New value: +"Path to a .stl (binary or ASCII), .obj or .3mf mesh, or a .step/.stp file. One of file / data is required. Hosted: `code`, `project:<slug>` (head), or a Studio `/p/<slug>?version=N` link (pinned); no local files. Hosted server: pass an https:// URL, a data: URI, or \"asset:<id>\" from request_upload — not a path on your machine."
  2. Changed15 schema fields changed
    • changedInput schema / properties / data / description
      Previous value: -"Mesh bytes as base64 — use when the server cannot see your filesystem."New value: +"Mesh or STEP bytes as base64 — use when the server cannot see your filesystem."
    • 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. Hosted server: pass an https:// URL, a data: URI, or \"asset:<id>\" from request_upload — not a path on your machine."New value: +"Path to a .stl (binary or ASCII), .obj or .3mf mesh, or a .step/.stp file. 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."
    • changedInput schema / properties / format / description
      Previous value: -"Format override; default from the extension or the content."New value: +"Format override; default from the extension or the content (an ISO-10303-21 header is STEP)."
    • changedInput schema / properties / format / enum
      Previous value: -[
      -  "stl",
      -  "obj",
      -  "3mf"
      -]New value: +[
      +  "stl",
      +  "obj",
      +  "3mf",
      +  "step"
      +]
    • removedInput schema / properties / maxDeviationMm
      Removed value: -{
      -  "description": "Max surface deviation (mm) a faithful verdict allows. Default max(0.25, 0.1 % of the bbox diagonal).",
      -  "type": "number"
      -}
    • removedInput schema / properties / maxPasses
      Removed value: -{
      -  "description": "Refinement passes, 1–4. Default 4; stops early at the first faithful pass.",
      -  "type": "number"
      -}
    • removedInput schema / properties / maxTriangles
      Removed value: -{
      -  "description": "Refuse meshes above this triangle count instead of stalling. Default 300000.",
      -  "type": "number"
      -}
    • addedInput schema / properties / max_deviation_mm
      Added value: +{
      +  "description": "Max surface deviation (mm) a faithful verdict allows. Default max(0.25, 0.1 % of the bbox diagonal).",
      +  "type": "number"
      +}
    • addedInput schema / properties / max_passes
      Added value: +{
      +  "description": "Refinement passes, 1–4. Default 4; stops early at the first faithful pass.",
      +  "type": "number"
      +}
    • addedInput schema / properties / max_triangles
      Added value: +{
      +  "description": "Refuse meshes above this triangle count instead of stalling. Default 300000.",
      +  "type": "number"
      +}
    • removedInput schema / properties / minIoU
      Removed value: -{
      -  "description": "Volume IoU a faithful verdict requires. Default 0.98.",
      -  "type": "number"
      -}
    • addedInput schema / properties / min_iou
      Added value: +{
      +  "description": "Volume IoU a faithful verdict requires. Default 0.98.",
      +  "type": "number"
      +}
    • addedInput schema / properties / solid
      Added value: +{
      +  "description": "STEP only: 0-based solid to rebuild when the file holds more than one (inspect with of: \"step\" lists them). A multi-solid STEP without it is refused.",
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • removedInput schema / properties / weldToleranceMm
      Removed value: -{
      -  "description": "Vertex weld distance in mm. Default max(1e-4, 1e-6 × bbox diagonal).",
      -  "type": "number"
      -}
    • addedInput schema / properties / weld_tolerance_mm
      Added value: +{
      +  "description": "Vertex weld distance in mm. Default max(1e-4, 1e-6 × bbox diagonal).",
      +  "type": "number"
      +}
  3. 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"
      -]
  4. 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."
  5. 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."
  6. Added

TDQS

Score is being calculated.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.