Skip to main content
Glama

Add Feature

add_feature
Idempotent

Use this when you need to insert a new feature line into a script. Insert a new feature line into a kernelCAD script before the last top-level return statement. Returns the modified code as text plus diagnostics from re-evaluating the result. Direct editing is authored here too: use body.deleteFace(faces) to heal a removed-face opening, or body.replaceFace(faces, { origin, normal }) for a parallel planar replacement; the runtime refuses any result that does not pass its single-solid BRepCheck gate. Primitives that accept faceLabels (box, cylinder, extrudeRect, extrudeCircle, extrudePolygon, extrudeRoundedRect) can receive opts.faceLabels in the inserted code — use lookup_api to see featureKindFaceLabels for the full value schema.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>",
      "feature_code": "<feature_code>"
    },
    "name": "add_feature"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesThe .kcad.ts source code.
feature_codeYesSingle-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, unlabeled 360-degree revolve followed only by finite translations, finite rotations about an axis of finite positive squared length, uniform scales by one finite positive factor, and reflections across a cardinal plane with a finite optional offset, with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. A rotated, uniformly scaled or reflected result is certified only when its final torus support frame, read from the built face and normalized by the product k of the scale factors, is within 2^-30 of an orthonormal frame and of the source tube ratio; the bounds carry that distortion. Every certificate is conditional on unproved assumptions: an OCCT TORUS support evaluates the closed-form torus formula, and, for a rotated, scaled or reflected result, OCCT evaluates the torus derivatives at u = v = 0 with relative error at most 2^-40. Non-uniform scale, malformed reflection planes, face labels, downstream consumers, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / feature_code / description
      Previous value: -"Single-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, unlabeled 360-degree revolve followed only by finite translations, finite rotations about an axis of finite positive squared length, and uniform scales by one finite positive factor, with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. A rotated or uniformly scaled result is certified only when its final torus support frame, read from the built face and normalized by the product k of the scale factors, is within 2^-30 of an orthonormal frame and of the source tube ratio; the bounds carry that distortion. Every certificate is conditional on unproved assumptions: an OCCT TORUS support evaluates the closed-form torus formula, and, for a rotated or scaled result, OCCT evaluates the torus derivatives at u = v = 0 with relative error at most 2^-40. Non-uniform scale/reflection, face labels, downstream consumers, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."New value: +"Single-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, unlabeled 360-degree revolve followed only by finite translations, finite rotations about an axis of finite positive squared length, uniform scales by one finite positive factor, and reflections across a cardinal plane with a finite optional offset, with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. A rotated, uniformly scaled or reflected result is certified only when its final torus support frame, read from the built face and normalized by the product k of the scale factors, is within 2^-30 of an orthonormal frame and of the source tube ratio; the bounds carry that distortion. Every certificate is conditional on unproved assumptions: an OCCT TORUS support evaluates the closed-form torus formula, and, for a rotated, scaled or reflected result, OCCT evaluates the torus derivatives at u = v = 0 with relative error at most 2^-40. Non-uniform scale, malformed reflection planes, face labels, downstream consumers, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."
  2. Changed1 schema field changed
    • changedInput schema / properties / feature_code / description
      Previous value: -"Single-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, unlabeled 360-degree revolve followed only by finite translations and finite rotations about an axis of finite positive squared length, with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. A rotated result is certified only when its final torus support frame, read from the built face, is within 2^-30 of an orthonormal frame and of the source tube ratio; the bounds carry that distortion. Every certificate is conditional on unproved assumptions: an OCCT TORUS support evaluates the closed-form torus formula, and, for a rotated result, OCCT evaluates the torus derivatives at u = v = 0 with relative error at most 2^-40. Scale/reflection, face labels, downstream consumers, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."New value: +"Single-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, unlabeled 360-degree revolve followed only by finite translations, finite rotations about an axis of finite positive squared length, and uniform scales by one finite positive factor, with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. A rotated or uniformly scaled result is certified only when its final torus support frame, read from the built face and normalized by the product k of the scale factors, is within 2^-30 of an orthonormal frame and of the source tube ratio; the bounds carry that distortion. Every certificate is conditional on unproved assumptions: an OCCT TORUS support evaluates the closed-form torus formula, and, for a rotated or scaled result, OCCT evaluates the torus derivatives at u = v = 0 with relative error at most 2^-40. Non-uniform scale/reflection, face labels, downstream consumers, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."
  3. Changed1 schema field changed
    • changedInput schema / properties / feature_code / description
      Previous value: -"Single-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, unlabeled 360-degree revolve followed only by finite translations, with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. Rotations, scale/reflection, face labels, downstream consumers, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."New value: +"Single-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, unlabeled 360-degree revolve followed only by finite translations and finite rotations about an axis of finite positive squared length, with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. A rotated result is certified only when its final torus support frame, read from the built face, is within 2^-30 of an orthonormal frame and of the source tube ratio; the bounds carry that distortion. Every certificate is conditional on unproved assumptions: an OCCT TORUS support evaluates the closed-form torus formula, and, for a rotated result, OCCT evaluates the torus derivatives at u = v = 0 with relative error at most 2^-40. Scale/reflection, face labels, downstream consumers, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."
  4. Changed1 schema field changed
    • changedInput schema / properties / feature_code / description
      Previous value: -"Single-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, untransformed, unlabeled 360-degree revolve with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. Face-labeled, transformed, downstream-consumed, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."New value: +"Single-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, unlabeled 360-degree revolve followed only by finite translations, with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. Rotations, scale/reflection, face labels, downstream consumers, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."
  5. Changed1 schema field changed
    • changedInput schema / properties / feature_code / description
      Previous value: -"Single-statement source line to insert. A full-turn G4 revolve has a narrow analytic certificate only for a terminal, untransformed revolve with no downstream feature consumers or face labels, using an exact unsegmented two-semicircle circle whose captured binary64 points prove exact dyadic symmetry, an exactly representable minor radius, and R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. Face-labeled, transformed, downstream-consumed, segmented, near-circular, axis-touching/crossing, partial-turn, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."New value: +"Single-statement source line to insert. A narrow analytic G4 certificate is available only for a terminal, untransformed, unlabeled 360-degree revolve with no downstream consumers, using a move + 2–128 three-point arcs + close profile. Exact dyadic checks require the move point and a later endpoint to be antipodal, every endpoint and midpoint on the same exactly representable circle, and exact cyclic ordering that proves the arcs partition it once without gaps or overlaps; the circle must satisfy R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. Face-labeled, transformed, downstream-consumed, near-circular, axis-touching/crossing, partial-turn, malformed, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."
  6. Changed1 schema field changed
    • changedInput schema / properties / feature_code / description
      Previous value: -"Single-statement source line to insert (e.g. `const hole = cylinder(5, 2).translate(10, 10, -1);`). For a full-turn revolve, use `const ring = path().circle(20, 0, 5).revolve({ continuity: 'G4' });` to request sampled seam evidence only. The diagnostic reports built-B-rep shared-edge counts and D0–D4 station measurements with separate shape-validity and volume checks; nine stations do not prove seam-wide G4 continuity or continuity across face interiors."New value: +"Single-statement source line to insert. A full-turn G4 revolve has a narrow analytic certificate only for a terminal, untransformed revolve with no downstream feature consumers or face labels, using an exact unsegmented two-semicircle circle whose captured binary64 points prove exact dyadic symmetry, an exactly representable minor radius, and R > r > 0. The lowerer constructs one OCCT analytic torus face, independently enumerates both closed periodic self-seams, measures both stored p-curve branches at finite D0–D4 stations within edge-tolerance limits, and requires a valid nonempty one-solid result with finite positive volume. An outward-rounded torus period bound covers the full seam domains; station readings are conformance checks, not the proof. Face-labeled, transformed, downstream-consumed, segmented, near-circular, axis-touching/crossing, partial-turn, incomplete, and otherwise unsupported cases remain sampled or uncertified; nine stations alone do not prove continuity."
  7. Changed1 schema field changed
    • changedInput schema / properties / feature_code / description
      Previous value: -"Single-statement source line to insert (e.g. `const hole = cylinder(5, 2).translate(10, 10, -1);`)."New value: +"Single-statement source line to insert (e.g. `const hole = cylinder(5, 2).translate(10, 10, -1);`). For a full-turn revolve, use `const ring = path().circle(20, 0, 5).revolve({ continuity: 'G4' });` to request sampled seam evidence only. The diagnostic reports built-B-rep shared-edge counts and D0–D4 station measurements with separate shape-validity and volume checks; nine stations do not prove seam-wide G4 continuity or continuity across face interiors."
  8. 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"
      -]
  9. 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"
      +}
  10. First observed

TDQS

A3.7/5.0
Behavior4/5

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

Beyond annotations, the description discloses the return payload ('modified code as text plus diagnostics from re-evaluating the result'), the hard validation gate (runtime refuses any result failing the single-solid BRepCheck), and the two face-repair APIs available inside authored code. This is substantial added context. A minor tension exists with idempotentHint=true, since repeated insertion of the same line would appear to duplicate content, but nothing in the text directly contradicts the annotation.

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 use case and action, then behavior, then authoring detail, with no filler sentences. The closing sentence is dense and packs API names, a list of six primitives, and a cross-reference into one breath, which costs some readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With annotations, a full input schema, and an output schema present, the description covers insertion point, return value, and the validation gate that determines success. The remaining gap is dispatch guidance relative to sibling add_* tools and failure-mode detail, which is minor given the rich structured fields.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/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 heavy burden, making 3 the baseline. The description adds some meaning: the feature_code must be a single statement placed before the last top-level return, and inserted code may pass opts.faceLabels for primitives that accept faceLabels, with a pointer to lookup_api. Useful, but the exhaustive certificate detail lives in the schema rather than the description.

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 names a specific verb and resource ('insert a new feature line into a kernelCAD script') and even pinpoints placement ('before the last top-level return statement'), so an agent knows exactly what the tool produces. It does not explicitly contrast itself with siblings like add_pattern_feature or remove_feature, which keeps it off a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is an opening when-to-use clause ('Use this when you need to insert a new feature line into a script'), which is genuine but generic. No when-not conditions, prerequisites, or named alternatives are given, and the only routing hint is to consult lookup_api for the faceLabels value schema.

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.