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

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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"
      -]
  2. 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."
  3. 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"
      +      ]
      +    }
      +  }
      +]
  4. 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"
      -      ]
      -    }
      -  }
      -]
  5. 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"
      +      ]
      +    }
      +  }
      +]
  6. 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"
      +}
  7. Added

TDQS

Score is being calculated.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.