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 lowerer measures NURBS station seams for C1/C2 requests; C2 targets at least G2 and emits a warning with the achieved class if missed. 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.

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": {
      "code": "<code>",
      "sections": "<sections>"
    },
    "name": "add_variable_sweep"
  }
}

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 request; default 'C1'. C2 targets measured G2 at NURBS station seams; output diagnostics report the achieved class.
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. Changed1 schema field changed
    • changedInput schema / properties / continuity / description
      Previous value: -"Inter-section continuity; default 'C1'."New value: +"Inter-section continuity request; default 'C1'. C2 targets measured G2 at NURBS station seams; output diagnostics report the achieved class."
  2. 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"
      +]
  3. 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"
      -]
  4. 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"
      +}
  5. 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."
  6. First observed

TDQS

A4.6/5.0
Behavior5/5

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

With readOnlyHint=false and idempotentHint=true already declared, the description still adds substantial behavior: exactly where the code is inserted (immediately before the last top-level return, empty code starts a new script), what the return payload contains (modified code, diagnostics, sweep volumeMm3/bbox, ok:false when nothing was built), and the fact that orientation is not yet exposed. It also discloses the C1/C2 continuity measurement behavior and warning emission, which annotations cannot convey.

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?

Front-loaded with the trigger condition and the exact function signature, then organized by concern (spine, sections, example, return, continuity, orientation). Nearly every sentence carries non-redundant information, though it is a dense run-on paragraph and the embedded example could be visually separated for faster scanning.

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?

This is a complex 8-parameter geometry-authoring tool, and the description covers spine sourcing, section ordering constraints, seam semantics, continuity behavior, return shape, and a worked example. An output schema exists, so return values need no further explanation, and the remaining caveats (unexposed orientation) are stated explicitly.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning beyond it: t is strictly increasing with first=0 and last=1, omitting t on every section spaces them evenly, and on a closed spine t=1 is the seam reusing the t=0 profile. Profiles are centred on the spine and turned to face along it, and sections require at least two entries. The one gap is the top-level `closed` boolean, which is never mentioned or reconciled with `spine_closed`.

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?

States a specific verb and resource ('organic swept solid whose cross-section changes along its length', 'variable-section sweep along a spine') and enumerates the concrete shapes it produces (taper, horn, bottle, ring band, fairing, duct). It also names the exact API call inserted into the source, which separates it from generic siblings like add_feature or add_surface.

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?

Opens with an explicit 'Use this when you need...' trigger and spells out the two alternative spine inputs (spine_points vs spine_binding) and two alternative profile inputs (inline radius/width+height vs profile_binding). It also tells the agent what to do with the result (return it or chain .union via add_feature). It does not explicitly say when to prefer a plain sweep or add_surface/apply_surface_blend instead, so it stops just short of full alternative routing.

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.