Skip to main content
Glama

Add Path Segment

add_path_segment
Idempotent

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 start_tangent/end_tangent (inserted as script opts startTangent/endTangent). Use for organic 2D outlines (eyewear brow, ergonomic handle, sneaker midsole).

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

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 control_points.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).
end_tangentNokind:'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)`).
start_tangentNokind:'spline' — optional [x, y] direction vector at points[0]. Magnitude is normalised internally; direction matters.
control_pointsNokind:'nurbs' — control-net vertices as Vec2 pairs in mm; at least degree+1 entries.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changed
    • changedInput schema / allOf
      Previous 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"
      -      ]
      -    }
      -  }
      -]New value: +[
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "spline"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "points"
      +      ]
      +    }
      +  },
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "nurbs"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "control_points"
      +      ]
      +    }
      +  },
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "hermite"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "a",
      +        "b"
      +      ]
      +    }
      +  }
      +]
    • removedInput schema / properties / controlPoints
      Removed value: -{
      -  "description": "kind:'nurbs' — control-net vertices as Vec2 pairs in mm; at least degree+1 entries.",
      -  "items": {
      -    "items": {
      -      "type": "number"
      -    },
      -    "maxItems": 2,
      -    "minItems": 2,
      -    "type": "array"
      -  },
      -  "type": "array"
      -}
    • addedInput schema / properties / control_points
      Added value: +{
      +  "description": "kind:'nurbs' — control-net vertices as Vec2 pairs in mm; at least degree+1 entries.",
      +  "items": {
      +    "items": {
      +      "type": "number"
      +    },
      +    "maxItems": 2,
      +    "minItems": 2,
      +    "type": "array"
      +  },
      +  "type": "array"
      +}
    • removedInput schema / properties / endTangent
      Removed value: -{
      -  "description": "kind:'spline' — optional [x, y] direction vector at points[N-1]. Magnitude is normalised internally; direction matters.",
      -  "items": {
      -    "type": "number"
      -  },
      -  "maxItems": 2,
      -  "minItems": 2,
      -  "type": "array"
      -}
    • addedInput schema / properties / end_tangent
      Added value: +{
      +  "description": "kind:'spline' — optional [x, y] direction vector at points[N-1]. Magnitude is normalised internally; direction matters.",
      +  "items": {
      +    "type": "number"
      +  },
      +  "maxItems": 2,
      +  "minItems": 2,
      +  "type": "array"
      +}
    • changedInput schema / properties / knots / description
      Previous value: -"kind:'nurbs' — optional explicit knot vector; length must equal controlPoints.length + degree + 1."New value: +"kind:'nurbs' — optional explicit knot vector; length must equal control_points.length + degree + 1."
    • removedInput schema / properties / startTangent
      Removed value: -{
      -  "description": "kind:'spline' — optional [x, y] direction vector at points[0]. Magnitude is normalised internally; direction matters.",
      -  "items": {
      -    "type": "number"
      -  },
      -  "maxItems": 2,
      -  "minItems": 2,
      -  "type": "array"
      -}
    • addedInput schema / properties / start_tangent
      Added value: +{
      +  "description": "kind:'spline' — optional [x, y] direction vector at points[0]. Magnitude is normalised internally; direction matters.",
      +  "items": {
      +    "type": "number"
      +  },
      +  "maxItems": 2,
      +  "minItems": 2,
      +  "type": "array"
      +}
  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. 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."
  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
    • 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"
      -      ]
      -    }
      -  }
      -]
  6. 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"
      +      ]
      +    }
      +  }
      +]
  7. 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"
      +}
  8. Added

TDQS

A4.4/5.0
Behavior4/5

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

Adds substantial context beyond the annotations: injection happens at the END of the chain immediately before `.close()`, the call requires an existing binding in `chain_anchor`, pen position must match the first point, and each kind fails closed on its own missing params. It also discloses the return ('modified code + diagnostics from re-evaluating'). There is mild tension between the 'Side-effect-free' claim and readOnlyHint=false; it is defensible (no persistent mutation, just re-evaluation) but not fully reconciled.

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 triggering condition and chain-injection rule, then structured as a per-kind bulleted list that mirrors the enum. It is long, and a few clauses duplicate schema descriptions (weights strictly positive, degree default 3), but every sentence carries operational or geometric information rather than filler.

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 14-parameter tool with nested endpoint objects and an output schema, the description covers the decision (which kind), the preconditions (chain anchor exists, pen position match), the failure mode (fail closed per kind), and points to the return payload. Nothing an agent needs to issue a correct call is missing.

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 already 100%, so the baseline would be 3; the description earns above that by adding cross-parameter meaning the schema cannot express — which params apply to which `kind`, tangent magnitude being the first derivative (~ chord length) rather than unit length, curvature defaulting to [0,0] (G1), knot vector length tied to control-point count plus degree. Some bullets do restate schema text, keeping it from a 5.

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 — append a curved path segment to an existing PathBuilder chain — and names the three segment kinds with their underlying geometry calls. It also pins the target use case (freeform/organic 2D outlines like an eyewear brow or sneaker midsole), which lets an agent separate it from nearby tools such as add_curve or add_surface without opening the schema.

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 explicit when-to-use framing ('Use this when you need a freeform/organic 2D outline') and gives concrete motivating examples. It tells the agent how to choose among the three `kind` values via the spline/nurbs/hermite breakdown. It does not name a sibling alternative to use instead when the profile is not organic, so the exclusions half of the when/when-not pair is missing.

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.