Skip to main content
Glama

Add Variable Sweep

add_variable_sweep
Idempotent

Use this when you need an organic swept solid whose cross-section changes along its length — a tapering body, horn, bottle, handle, ring band, fairing, or duct — authored as a variable-section sweep along a spine. Inserts variableSweep(spine, sections, opts?) into the .kcad.ts code immediately before the last top-level return (an empty code starts a new script that returns the sweep). Spine: EITHER spine_points ([[x,y,z], ...] in mm, interpolated with spline3d; spine_closed: true closes the loop for a ring) OR spine_binding (an existing Curve3D / Sketch / Vec3[] variable). Each section: t in [0, 1] plus a profile — inline radius (circle) or width + height (rectangle), or profile_binding (an existing Sketch); profiles are centred on the spine and turned to face along it. Sections are strictly increasing in t, first t=0, last t=1 (omit t on every section to space them evenly). On a closed spine t=1 is the seam and reuses the t=0 profile. Example: { code, spine_points: [[0,0,0],[0,10,30],[0,0,60]], sections: [{ t: 0, radius: 8 }, { t: 0.5, radius: 10 }, { t: 1, radius: 4 }] }. Returns the modified code, diagnostics from re-evaluating it, and sweep { volumeMm3, bbox } measured from the built solid (ok:false when the sweep built nothing). The result is a Shape binding: return it, or chain .union(...) etc. via add_feature. Orientation is not exposed by this MCP tool until runtime orientation support is wired. Side-effect-free.

Input Schema

NameRequiredDescriptionDefault
codeYesThe .kcad.ts source code ("" for a new script).
closedNoOptional closed-sweep flag.
sectionsYesVarying cross-sections along the spine; at least 2 entries, strictly increasing in `t`, first t=0, last t=1.
continuityNoInter-section continuity; default 'C1'.
binding_nameNoJS const name for the new Shape binding (default: _sweep_<N>).
spine_closedNoWith spine_points: close the spline into a loop (ring band, loop handle).
spine_pointsNoInline spine: at least 2 [x, y, z] points in mm, interpolated with spline3d. Use this OR spine_binding.
spine_bindingNoExisting variable name for a Curve3D / Sketch / Vec3[] declared earlier in the source. Use this OR spine_points.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed10 schema fields changed
    • changedInput schema / properties / code / description
      Previous value: -"The .kcad.ts source code."New value: +"The .kcad.ts source code (\"\" for a new script)."
    • addedInput schema / properties / sections / items / properties / height
      Added value: +{
      +  "description": "Inline rectangular profile height, mm (with width).",
      +  "type": "number"
      +}
    • changedInput schema / properties / sections / items / properties / profile_binding / description
      Previous value: -"Existing Sketch variable name for this section."New value: +"Existing Sketch variable name for this section (instead of radius / width+height)."
    • addedInput schema / properties / sections / items / properties / radius
      Added value: +{
      +  "description": "Inline circular profile radius, mm.",
      +  "type": "number"
      +}
    • addedInput schema / properties / sections / items / properties / width
      Added value: +{
      +  "description": "Inline rectangular profile width, mm (with height).",
      +  "type": "number"
      +}
    • removedInput schema / properties / sections / items / required
      Removed value: -[
      -  "t",
      -  "profile_binding"
      -]
    • changedInput schema / properties / spine_binding / description
      Previous value: -"Existing variable name for a Curve3D / Sketch / Vec3[] declared earlier in the source."New value: +"Existing variable name for a Curve3D / Sketch / Vec3[] declared earlier in the source. Use this OR spine_points."
    • addedInput schema / properties / spine_closed
      Added value: +{
      +  "description": "With spine_points: close the spline into a loop (ring band, loop handle).",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / spine_points
      Added value: +{
      +  "description": "Inline spine: at least 2 [x, y, z] points in mm, interpolated with spline3d. Use this OR spine_binding.",
      +  "items": {
      +    "items": {
      +      "type": "number"
      +    },
      +    "maxItems": 3,
      +    "minItems": 3,
      +    "type": "array"
      +  },
      +  "type": "array"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "code",
      -  "spine_binding",
      -  "sections"
      -]New value: +[
      +  "code",
      +  "sections"
      +]
  2. Changed2 schema fields changed
    • removedOutput schema / properties
      Removed value: -{
      -  "binding_name": {
      -    "description": "JS const name bound to the new construct (when one was created).",
      -    "type": "string"
      -  },
      -  "diagnostics": {
      -    "description": "Diagnostics from re-evaluating the modified source.",
      -    "items": {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  "error": {
      -    "description": "Failure message (present when ok is false).",
      -    "type": "string"
      -  },
      -  "new_code": {
      -    "description": "Modified .kcad.ts source (present on success). Caller persists it.",
      -    "type": "string"
      -  },
      -  "ok": {
      -    "description": "Whether the edit applied and re-evaluated cleanly.",
      -    "type": "boolean"
      -  }
      -}
    • removedOutput schema / required
      Removed value: -[
      -  "ok"
      -]
  3. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "properties": {
      +    "binding_name": {
      +      "description": "JS const name bound to the new construct (when one was created).",
      +      "type": "string"
      +    },
      +    "diagnostics": {
      +      "description": "Diagnostics from re-evaluating the modified source.",
      +      "items": {
      +        "additionalProperties": true,
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "error": {
      +      "description": "Failure message (present when ok is false).",
      +      "type": "string"
      +    },
      +    "new_code": {
      +      "description": "Modified .kcad.ts source (present on success). Caller persists it.",
      +      "type": "string"
      +    },
      +    "ok": {
      +      "description": "Whether the edit applied and re-evaluated cleanly.",
      +      "type": "boolean"
      +    }
      +  },
      +  "required": [
      +    "ok"
      +  ],
      +  "type": "object"
      +}
  4. Changed1 schema field changed
    • changedInput schema / properties / sections / description
      Previous value: -"Varying cross-sections along the spine; at least 2 entries, strictly increasing in `t`."New value: +"Varying cross-sections along the spine; at least 2 entries, strictly increasing in `t`, first t=0, last t=1."
  5. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Beyond the annotations, it discloses the exact insertion point in `.kcad.ts` code, behavior for empty `code`, return contents including diagnostics and `sweep` measurements, `ok:false` when nothing is built, and that the result is a Shape binding. It also explicitly notes the current orientation limitation and says the operation is side-effect-free.

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

Conciseness4/5

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

The description is front-loaded with the use case and then proceeds through spine, section, example, and return behavior in a logical order. It is dense but appropriately sized for a complex eight-parameter tool, though the long first sentence and packed clauses make it slightly harder to scan.

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?

Given the eight parameters, mutation semantics, output schema, and geometry complexity, the description covers the insertion behavior, spine and section rules, result binding semantics, failure signal, and orientation limitation. It is complete enough for an agent to invoke the tool correctly without opening additional docs.

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

Parameters5/5

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

Although schema coverage is 100%, the description adds meaningful semantics beyond the schema: `spine_points` are interpolated with `spline3d`, `spine_closed` forms a loop, sections are strictly increasing in `t` with first 0 and last 1, and profiles are centered on the spine and turned to face along it. It also explains that omitting `t` spaces sections evenly and that `t=1` on a closed spine reuses the `t=0` profile.

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?

The description states a specific verb and resource: insert `variableSweep(spine, sections, opts?)` to create an organic swept solid whose cross-section changes along a length. It distinguishes the operation from generic curves/surfaces by emphasizing variable-section sweeps along a spine and naming concrete use cases such as tapering bodies, horns, and ducts.

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?

It gives a clear triggering condition: use this when the desired solid is a variable-section sweep. It also explains how the result can be chained via `add_feature`, but it does not explicitly name when-not-to-use alternatives or sibling tools for constant-section sweeps.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.