Skip to main content
Glama

Add Path Segment

add_path_segment

Use this when you need a freeform/organic 2D outline — an eyewear brow, ergonomic grip, sneaker midsole, or body silhouette — by appending a curved segment to an existing PathBuilder chain on the named chain_anchor variable. The call is injected at the END of the chain, immediately before any .close(). One segment kind, selected by kind:

  • 'spline' — .spline(points, opts?): interpolates through every points waypoint (Vec2[] mm, >= 2 entries; points[0] must match current pen position). Optional tension, and startTangent/endTangent 2D direction vectors that constrain the first-derivative direction at the endpoints (magnitude normalised internally). Use for organic 2D outlines (eyewear brow, ergonomic handle, sneaker midsole).

  • 'nurbs' — .nurbsSegment(controlPoints, opts?): explicit B-spline net (Vec2[] mm, >= degree+1 entries; controlPoints[0] must match pen; pen ends at controlPoints[N-1]). Optional degree (default 3), rational weights (strictly positive), explicit knots (length = controlPoints.length + degree + 1).

  • 'hermite' — .hermiteG2(a, b): each endpoint { point: Vec2, tangent: Vec2, curvature?: Vec2 } in mm (a.point must match pen; pen ends at b.point). curvature defaults to [0,0] (G1); pass matching curvatures for G2 blends. Tangent magnitude is the first derivative (~ chord length), NOT unit length. Returns the modified code + diagnostics from re-evaluating. Side-effect-free. Each kind fails closed on its own missing required params.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aNokind:'hermite' — start endpoint; point must match current pen position within 1e-6 mm.
bNokind:'hermite' — end endpoint; pen ends at b.point.
codeYesThe .kcad.ts source code.
kindYesWhich path-segment kind to append.
knotsNokind:'nurbs' — optional explicit knot vector; length must equal controlPoints.length + degree + 1.
degreeNokind:'nurbs' — B-spline degree (default 3).
pointsNokind:'spline' — waypoints as Vec2 pairs in mm; at least 2 entries; first must match current pen position.
tensionNokind:'spline' — optional Catmull-Rom-style stiffness; forwarded to the underlying B-spline approximation.
weightsNokind:'nurbs' — optional rational weights (one per control point; strictly positive).
endTangentNokind:'spline' — optional [x, y] direction vector at points[N-1]. Magnitude is normalised internally; direction matters.
binding_nameNoReserved for future use; the segment injection mutates the chain anchor in place.
chain_anchorYesJS identifier of an existing PathBuilder binding (e.g. `const brow = path().moveTo(0,0)`).
startTangentNokind:'spline' — optional [x, y] direction vector at points[0]. Magnitude is normalised internally; direction matters.
controlPointsNokind:'nurbs' — control-net vertices as Vec2 pairs in mm; at least degree+1 entries.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYesWhether the edit applied and re-evaluated cleanly.
errorNoFailure message (present when ok is false).
new_codeNoModified .kcad.ts source (present on success). Caller persists it.
diagnosticsNoDiagnostics from re-evaluating the modified source.
binding_nameNoJS const name bound to the new construct (when one was created).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changed
    • addedInput schema / properties / a / properties / curvature / description
      Added value: +"Optional second derivative; defaults to [0, 0] (G1-only)."
    • addedInput schema / properties / a / properties / point / description
      Added value: +"Endpoint position in mm."
    • addedInput schema / properties / a / properties / tangent / description
      Added value: +"First derivative (~ chord length), NOT unit length."
    • changedInput schema / properties / b / description
      Previous value: -"kind:'hermite' — end endpoint."New value: +"kind:'hermite' — end endpoint; pen ends at b.point."
    • addedInput schema / properties / b / properties / curvature / description
      Added value: +"Optional second derivative; defaults to [0, 0] (G1-only)."
    • addedInput schema / properties / b / properties / point / description
      Added value: +"Endpoint position in mm."
    • addedInput schema / properties / b / properties / tangent / description
      Added value: +"First derivative (~ chord length), NOT unit length."
  2. Changed1 schema field changed
    • addedInput schema / allOf
      Added value: +[
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "spline"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "points"
      +      ]
      +    }
      +  },
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "nurbs"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "controlPoints"
      +      ]
      +    }
      +  },
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "hermite"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "a",
      +        "b"
      +      ]
      +    }
      +  }
      +]
  3. Changed1 schema field changed
    • removedInput schema / allOf
      Removed value: -[
      -  {
      -    "if": {
      -      "properties": {
      -        "kind": {
      -          "const": "spline"
      -        }
      -      }
      -    },
      -    "then": {
      -      "required": [
      -        "points"
      -      ]
      -    }
      -  },
      -  {
      -    "if": {
      -      "properties": {
      -        "kind": {
      -          "const": "nurbs"
      -        }
      -      }
      -    },
      -    "then": {
      -      "required": [
      -        "controlPoints"
      -      ]
      -    }
      -  },
      -  {
      -    "if": {
      -      "properties": {
      -        "kind": {
      -          "const": "hermite"
      -        }
      -      }
      -    },
      -    "then": {
      -      "required": [
      -        "a",
      -        "b"
      -      ]
      -    }
      -  }
      -]
  4. Changed1 schema field changed
    • addedInput schema / allOf
      Added value: +[
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "spline"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "points"
      +      ]
      +    }
      +  },
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "nurbs"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "controlPoints"
      +      ]
      +    }
      +  },
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "hermite"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "a",
      +        "b"
      +      ]
      +    }
      +  }
      +]
  5. 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"
      +}
  6. Added

TDQS

A4.7/5.0
Behavior5/5

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

Annotations are minimal (readOnlyHint=false, destructiveHint=false), so the description carries the burden. It discloses that the tool mutates the chain anchor in place, returns modified code plus diagnostics from re-evaluation, is side-effect-free, and fails closed on missing required params. It also explains the exact injection point. This goes well beyond the annotations and gives the agent a complete behavioral picture.

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 long but well-structured, with a front-loaded usage sentence followed by bullet-style breakdown of the three segment kinds. Every sentence conveys useful information without fluff. It is appropriately detailed for a tool with three variants and 14 parameters, though it could be slightly tightened without losing clarity.

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?

For a complex tool with three segment kinds, nested objects, and conditional requirements, the description is thorough: it covers the injection point, per-kind parameter constraints (including matching pen position), optional parameters, return value, side-effect behavior, and error handling. Nothing an agent needs to invoke it correctly is missing, especially given the rich input schema and output schema.

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?

Even though the schema has 100% description coverage, the tool description adds substantial semantic value: it explains each kind's behavior (e.g., spline interpolates through waypoints, tangents are normalized internally, hermite curvature defaults to G1), enforces constraints like points[0] matching the pen position, and clarifies optional parameters like tension, degree, weights, and knots. This goes far beyond the schema's field-level descriptions.

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 clearly states the tool appends a curved segment to an existing PathBuilder chain on a named chain_anchor variable, with three specific kinds (spline, nurbs, hermite). It gives concrete use cases (eyewear brow, ergonomic grip, sneaker midsole) and distinguishes itself from other 'add_*' siblings by focusing on path segments. The verb-resource pair is unambiguous.

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?

The description explicitly says 'Use this when you need a freeform/organic 2D outline...' and specifies that the call is injected at the END of the chain before any .close(). It provides clear context for when to use it but does not explicitly mention alternatives or when not to use it. The guidance is strong, though it stops short of naming competing tools.

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.