Skip to main content
Glama

Add Path Segment

add_path_segment

Use this when you need to append 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).

TDQS

A4.5/5.0
Behavior4/5

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

Annotations are minimal (readOnlyHint=false, destructiveHint=false). The description adds significant value by stating it is 'Side-effect-free', 'fails closed on missing params', and returns modified code with diagnostics. It does not detail idempotency or concurrency, but the added context is strong.

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 well-structured and front-loaded, but somewhat lengthy due to detailed kind breakdowns. It could be slightly more concise, but each sentence earns its place by providing necessary constraints and examples.

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 complexity (3 kinds, 14 params, nested objects, output schema), the description is comprehensive: explains insertion point, pen position constraints, return value, and kind-specific details. The existence of an output schema reduces need to describe return format.

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?

Schema coverage is 100%, but the description adds substantial meaning beyond schema: for spline, it explains interpolation, tangent normalization; for nurbs, the B-spline net; for hermite, tangent magnitude meaning. These enrich parameter understanding without redundancy.

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, specifies the three kinds (spline, nurbs, hermite) with code examples and constraints, and distinguishes itself from sibling tools like add_curve by focusing on path segment appending.

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 to append a curved segment to an existing PathBuilder chain' and provides guidance on when to use each kind (e.g., 'Use for organic 2D outlines'). However, it lacks explicit when-not-to-use or comparison with sibling tools like add_curve, limiting differentiation.

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.

TDQS

A3.9/5.0
Disambiguation4/5

Tools are mostly distinct, with clear descriptions for each. However, there is some potential overlap between inspection tools like 'inspect' and 'mesh_summary', and between rendering tools 'render_preview' and 'get_latest_render', which could cause minor confusion.

Naming Consistency5/5

All tool names follow a consistent snake_case verb_noun pattern, making it predictable for an agent to infer functionality.

Tool Count2/5

44 tools is significantly higher than the typical well-scoped range of 3-15. While the domain is complex, the count feels excessive and could overwhelm an agent.

Completeness4/5

The tool set covers an extensive range of CAD operations including creation, inspection, rendering, export, and verification. Minor gaps exist, such as direct sketch editing tools, but overall it is comprehensive.