Skip to main content
Glama

Add Pattern Feature

add_pattern_feature
Idempotent

Use this when you need to repeat a feature in a pattern. Insert a Shape.patternLinear / .patternCircular / .patternGrid call into a kernelCAD script before the last top-level return. Pass structured args (kind + the matching spec object). Returns the modified code plus diagnostics from re-evaluating. Side-effect-free. The pattern feature is a single editable unit; pattern-instance face refs resolve via <sourceId>_pattern_<i> on the pattern feature's lineage. Geometric note: pattern is implemented as cumulative boolean union of transformed source copies — additive features (boxes, ribs, fins, spokes) pattern cleanly; patterning a subtractive feature (hole, cutout) only preserves the per-instance void when adjacent bodies are disjoint.

Input Schema

NameRequiredDescriptionDefault
codeYesThe .kcad.ts source code.
gridNoRequired when kind=grid.
kindYes
linearNoRequired when kind=linear.
targetYesVariable name of the Shape to pattern (inserted verbatim as the LHS receiver).
circularNoRequired when kind=circular.
assign_toNoOptional const-binding name; emits `const <assign_to> = <target>.patternX(...);`. Omit for statement form.

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 / allOf
      Added value: +[
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "linear"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "linear"
      +      ]
      +    }
      +  },
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "circular"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "circular"
      +      ]
      +    }
      +  },
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "grid"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "grid"
      +      ]
      +    }
      +  }
      +]
    • addedInput schema / properties / grid / properties / x / description
      Added value: +"First grid axis."
    • addedInput schema / properties / grid / properties / x / properties
      Added value: +{
      +  "count": {
      +    "minimum": 2,
      +    "type": "integer"
      +  },
      +  "direction": {
      +    "items": {
      +      "type": "number"
      +    },
      +    "maxItems": 3,
      +    "minItems": 3,
      +    "type": "array"
      +  },
      +  "spacing": {
      +    "type": "number"
      +  }
      +}
    • addedInput schema / properties / grid / properties / x / required
      Added value: +[
      +  "count",
      +  "direction",
      +  "spacing"
      +]
    • addedInput schema / properties / grid / properties / y / description
      Added value: +"Second grid axis."
    • addedInput schema / properties / grid / properties / y / properties
      Added value: +{
      +  "count": {
      +    "minimum": 2,
      +    "type": "integer"
      +  },
      +  "direction": {
      +    "items": {
      +      "type": "number"
      +    },
      +    "maxItems": 3,
      +    "minItems": 3,
      +    "type": "array"
      +  },
      +  "spacing": {
      +    "type": "number"
      +  }
      +}
    • addedInput schema / properties / grid / properties / y / required
      Added value: +[
      +  "count",
      +  "direction",
      +  "spacing"
      +]
  3. Changed7 schema fields changed
    • removedInput schema / allOf
      Removed value: -[
      -  {
      -    "if": {
      -      "properties": {
      -        "kind": {
      -          "const": "linear"
      -        }
      -      }
      -    },
      -    "then": {
      -      "required": [
      -        "linear"
      -      ]
      -    }
      -  },
      -  {
      -    "if": {
      -      "properties": {
      -        "kind": {
      -          "const": "circular"
      -        }
      -      }
      -    },
      -    "then": {
      -      "required": [
      -        "circular"
      -      ]
      -    }
      -  },
      -  {
      -    "if": {
      -      "properties": {
      -        "kind": {
      -          "const": "grid"
      -        }
      -      }
      -    },
      -    "then": {
      -      "required": [
      -        "grid"
      -      ]
      -    }
      -  }
      -]
    • removedInput schema / properties / grid / properties / x / description
      Removed value: -"First grid axis."
    • removedInput schema / properties / grid / properties / x / properties
      Removed value: -{
      -  "count": {
      -    "minimum": 2,
      -    "type": "integer"
      -  },
      -  "direction": {
      -    "items": {
      -      "type": "number"
      -    },
      -    "maxItems": 3,
      -    "minItems": 3,
      -    "type": "array"
      -  },
      -  "spacing": {
      -    "type": "number"
      -  }
      -}
    • removedInput schema / properties / grid / properties / x / required
      Removed value: -[
      -  "count",
      -  "direction",
      -  "spacing"
      -]
    • removedInput schema / properties / grid / properties / y / description
      Removed value: -"Second grid axis."
    • removedInput schema / properties / grid / properties / y / properties
      Removed value: -{
      -  "count": {
      -    "minimum": 2,
      -    "type": "integer"
      -  },
      -  "direction": {
      -    "items": {
      -      "type": "number"
      -    },
      -    "maxItems": 3,
      -    "minItems": 3,
      -    "type": "array"
      -  },
      -  "spacing": {
      -    "type": "number"
      -  }
      -}
    • removedInput schema / properties / grid / properties / y / required
      Removed value: -[
      -  "count",
      -  "direction",
      -  "spacing"
      -]
  4. Changed7 schema fields changed
    • addedInput schema / allOf
      Added value: +[
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "linear"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "linear"
      +      ]
      +    }
      +  },
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "circular"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "circular"
      +      ]
      +    }
      +  },
      +  {
      +    "if": {
      +      "properties": {
      +        "kind": {
      +          "const": "grid"
      +        }
      +      }
      +    },
      +    "then": {
      +      "required": [
      +        "grid"
      +      ]
      +    }
      +  }
      +]
    • addedInput schema / properties / grid / properties / x / description
      Added value: +"First grid axis."
    • addedInput schema / properties / grid / properties / x / properties
      Added value: +{
      +  "count": {
      +    "minimum": 2,
      +    "type": "integer"
      +  },
      +  "direction": {
      +    "items": {
      +      "type": "number"
      +    },
      +    "maxItems": 3,
      +    "minItems": 3,
      +    "type": "array"
      +  },
      +  "spacing": {
      +    "type": "number"
      +  }
      +}
    • addedInput schema / properties / grid / properties / x / required
      Added value: +[
      +  "count",
      +  "direction",
      +  "spacing"
      +]
    • addedInput schema / properties / grid / properties / y / description
      Added value: +"Second grid axis."
    • addedInput schema / properties / grid / properties / y / properties
      Added value: +{
      +  "count": {
      +    "minimum": 2,
      +    "type": "integer"
      +  },
      +  "direction": {
      +    "items": {
      +      "type": "number"
      +    },
      +    "maxItems": 3,
      +    "minItems": 3,
      +    "type": "array"
      +  },
      +  "spacing": {
      +    "type": "number"
      +  }
      +}
    • addedInput schema / properties / grid / properties / y / required
      Added value: +[
      +  "count",
      +  "direction",
      +  "spacing"
      +]
  5. 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"
      +}
  6. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Goes well past the annotations: declares the re-evaluation diagnostics returned, the single-editable-unit semantics, the `<sourceId>_pattern_<i>` face-ref naming convention, and — most valuably — that pattern is a cumulative boolean union, so subtractive features only pattern cleanly across disjoint bodies. 'Side-effect-free' is consistent with a tool that rewrites caller-supplied code rather than project state.

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 when-to-use clause and then packed with genuinely load-bearing detail; no filler sentences. The geometric caveat is long and dense but earns its space because it changes whether the call will produce correct geometry.

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 7-parameter nested-object tool with an output schema, the description covers the parts structured fields cannot: the placement constraint, the discriminator pairing, the returned diagnostics, and the geometric limitation on subtractive patterning. An agent has everything needed to call it correctly.

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 86% and the if/then discriminators are machine-readable, but the description adds the human-level rule "Pass structured args (kind + the matching spec object)" that tells the agent how kind selects linear/circular/grid. It does not elaborate on count/spacing ranges or the optional angleDeg default, which the schema already covers.

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 (insert a Shape.patternLinear/.patternCircular/.patternGrid call into a kernelCAD script) and scopes it precisely relative to the broader add_feature sibling. The three pattern kinds and the required insertion point (before the last top-level return) make the operation unambiguous.

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?

"Use this when you need to repeat a feature in a pattern" gives a clear triggering condition, and it adds the mechanical precondition of inserting before the last top-level return. It never explicitly rules out alternatives such as add_feature or flatten_pattern, so the agent must infer the boundary itself.

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.