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 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

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

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

A3.5/5.0
Behavior1/5

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

The annotations declare `readOnlyHint: false`, but the description explicitly says the tool is 'Side-effect-free' and only 'Returns the modified code + diagnostics.' That is a direct contradiction of the read-only annotation. Although the description also usefully discloses injection location, fail-closed behavior, and per-kind requirements, the contradiction dominates this dimension.

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 definition is dense but appropriately sized for a 14-parameter tool with three conditional variants. It front-loads the main use case and organizes kind-specific details in a bullet list, though some material overlaps with the schema.

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 tool's complexity, conditional schema, annotations, and existing output schema, the description covers what an agent needs: when to use it, where the segment is injected, how each kind works, return behavior, side-effect claim, and fail-closed handling. No essential call-time context 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 description coverage is 100%, so the schema already carries the baseline parameter documentation. The description adds useful conceptual semantics beyond the schema, such as spline interpolation through every waypoint, NURBS as an explicit B-spline net, and Hermite G1 vs G2 tangent/curvature behavior.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific action and target: appending a curved segment to an existing PathBuilder chain via `chain_anchor`, with three segment kinds. It is clear enough to distinguish from unrelated tools, but does not explicitly differentiate itself from sibling curve/connector tools such as `add_curve` or `add_connector`.

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?

It gives explicit usage context, including use cases like eyewear brows, ergonomic grips, sneaker midsoles, and body silhouettes, plus the structural condition of appending before `.close()`. It does not state when not to use it or name sibling alternatives, which keeps it below a 5.

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.