Skip to main content
Glama

pcb_set_rule_properties

Update a named PCB design rule's metadata and constraint values, changing only the fields you specify while leaving all other settings untouched.

Instructions

Update metadata AND constraint values of a named PCB design rule.

Metadata fields always apply. Constraint fields are dispatched by the rule's underlying RuleKind:

  • Clearance (kind 0), ComponentClearance (kind 24), HoleToHoleClearance (kind 52) and BoardOutlineClearance (kind 63): gap_mils, or gap_mm when the value is metric. An integer mil field cannot express 0.2mm; it lands on 8 mils, which is 0.2032mm. Pass one or the other.

  • Width (kind 2): min_width_mils / max_width_mils / favored_width_mils (applied to every layer).

  • HoleSize (kind 42): min_hole_size_mils / max_hole_size_mils.

  • Routing Via: min_via_size_mils / max_via_size_mils / preferred_via_size_mils and the three *_via_hole_mils. Checked as a set first (minimum <= preferred <= maximum, every diameter larger than its hole) and each read back; the reply carries via_sizes_mils and via_sizes_written. A rule in template mode keeps checking its templates, and via_note says so; this cannot switch a rule between modes.

THE GAP WRITE IS READ BACK, not assumed. A rule kind that does not really carry Gap can accept the assignment and keep its old value, so the reply carries gap_written, gap_after_mm and, when it did not take, a note saying the rule still holds the old number. Kind 63 in particular is included on the strength of its position in the TRuleKind order rather than a documented interface, so let gap_written decide whether it worked rather than the count.

Pass only the parameters you want to change; everything else stays untouched. Each VERIFIED field write increments properties_updated in the response, so a refused constraint no longer inflates it.

NOTE: Priority is NOT writable from this tool. IPCB_Rule.Priority is a read-only function in the PCB scripting API (Function Priority : TRulePrecedence), not a property; there is no SetState_Priority or SetPriority method either. Assigning to it crashes the DelphiScript engine. To reorder rule priorities, drag them in Altium's UI (PCB > Rules and Constraints Editor; rules earlier in a category have higher priority).

Args: name: Rule name to update. enabled: Whether DRC enforces the rule. scope1 / scope2: Rule scope query expressions. A comparison joined by And/Or/Xor/Not must be bracketed ("IsPad And (HoleSize > 3)") or joined with &&; an unbracketed one is refused before anything is sent. comment: Free-form comment. gap_mils: Clearance gap. Applies to Clearance, ComponentClearance, and HoleToHoleClearance rules. min_width_mils / max_width_mils / favored_width_mils: Width constraint values (applied to every layer). min_hole_size_mils / max_hole_size_mils: HoleSize constraint limits.

Returns: Dict with name, rule_kind, and properties_updated count.

Input Schema

NameRequiredDescriptionDefault
nameYes
gap_mmNo
scope1No
scope2No
commentNo
enabledNo
gap_milsNo
max_width_milsNo
min_width_milsNo
max_via_hole_milsNo
max_via_size_milsNo
min_via_hole_milsNo
min_via_size_milsNo
favored_width_milsNo
max_hole_size_milsNo
min_hole_size_milsNo
preferred_via_hole_milsNo
preferred_via_size_milsNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.6.1

TDQS

A4.4/5.0
Behavior5/5

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

With no annotations to lean on, the description carries the full burden and does so unusually well: it discloses that writes are read back rather than assumed, that a non-Gap rule kind can silently retain its old gap, that Kind 63 is included on inference rather than a documented interface, and that properties_updated only counts verified writes. It also warns that assigning Priority crashes the DelphiScript engine, a concrete crash condition that is otherwise invisible.

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?

Purpose is front-loaded in the first sentence and the body is organized by RuleKind, which matches how an agent must reason about the 18 parameters. It is long and occasionally repeats itself (the gap read-back caveat is stated twice), but nearly every sentence carries non-obvious operational detail rather than restating the schema.

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?

For an 18-parameter mutation tool with no annotations and no schema descriptions, this is close to complete: it covers kind dispatch, unit traps, verification behavior, and the priority landmine. The one shortfall is the 'Returns' block, which lists only name, rule_kind, and properties_updated while the body additionally promises gap_written, gap_after_mm, via_sizes_mils, via_sizes_written, and via_note — an inconsistency the output schema may resolve but the description does not.

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 0%, so the description must compensate, and it does: it explains unit semantics, the gap_mils/gap_mm exclusivity and the precision trap (an integer mil field lands on 8 mils for a requested 0.2mm), the via-size set validation ordering (min <= preferred <= max, diameter > hole), and the bracket/&& requirement for scope query expressions. The only gap is gap_mm not appearing in the formal Args list despite being discussed in the body.

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?

Opens with a specific verb and resource: 'Update metadata AND constraint values of a named PCB design rule,' which immediately distinguishes it from read-side siblings like pcb_get_rule_properties and pcb_create_design_rule. It does not explicitly name or route away from pcb_set_rules_enabled, which also toggles a rule's enabled state, so the sibling differentiation is incomplete.

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?

Gives a clear operating contract — 'Pass only the parameters you want to change; everything else stays untouched' — plus a per-RuleKind table of which constraint fields apply to which rule kind, which is exactly the guidance an agent needs. It also routes the priority use case away from this tool to the Altium UI, though it never states when to use this tool versus pcb_set_rules_enabled or pcb_create_design_rule.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools