Skip to main content
Glama

pcb_create_design_rule

Defines a new PCB design rule for electrical clearance, track width, via size, differential pairs, mask expansion, or via-in-pad restrictions on the active board.

Instructions

Create a new design rule on the active PCB.

Args: name: Rule name (e.g., "Min Clearance 6mil"). rule_type: Type of rule to create. Options: "clearance" - Electrical clearance (value = gap in mils). "width" - Track width constraint (value = min width in mils; max_value / favored_value optional). "via_size" - Hole size constraint (value = min hole in mils; max_value optional). "differential_pairs" - Differential-pair routing rule (value = min gap, max_value = max gap, favored_value = preferred gap, max_uncoupled_length = max uncoupled length in mils). "solder_mask_expansion" - The mask opening at each pad and via site (value = radial expansion in mils, SIGNED). A negative value contracts the opening, which is how a via ends up covered. Scope it with "IsVia" to tent vias and leave pads alone. "paste_mask_expansion" - Same shape, stencil side (value = radial expansion in mils, signed). "vias_under_smd" - Whether the autorouter may put a via inside an SMD pad. Boolean: set allowed, not value. This is the DRC that catches via-in-pad, which needs filling and capping at fabrication. value: Rule's primary value in mils. For width / via_size / differential_pairs this is the MIN side. Default 10. max_value: For width / via_size / differential_pairs. When supplied, sets the MAX side independently of value. When None, falls back to 5x value (legacy default). favored_value: For width / differential_pairs. Sets the preferred value. Defaults to value when None. max_uncoupled_length: For differential_pairs only. MaxUncoupledLength in mils (single scalar, not per-layer). Defaults to 1000 mils when None. scope: Optional query expression for Scope1. Pick the predicate that matches the rule kind: - net-based rules (clearance, width, via_size): "InNet('GND')", "InNetClass('Power')", "All". - differential_pairs: "InDifferentialPair('USB')", "InDifferentialPairClass('HighSpeed')", "IsDifferentialPair" (matches any diff pair), or "All". Mixing predicates across kinds (e.g., InNet on a differential_pairs rule) creates a rule that never matches. Bracket a comparison joined by And/Or/Xor/Not: "IsPad And (HoleSize > 3)", or use &&/||. Altium binds And tighter than >, and an unbracketed "IsPad And HoleSize > 3" is refused before anything is sent, with the bracketed form in suggested_scope. net_scope: Which nets the rule applies between. Options: "different_nets" (default) for Clearance rules; "any_net" for all-pairs; "same_net" for same-net only. Has no effect on differential_pairs, and none on the mask or vias_under_smd kinds, which are not net-pair rules. allowed: For vias_under_smd only. False forbids a via inside an SMD pad. Omitted means True, which is Altium's own default and creates a rule that changes nothing, rather than one that silently bans via-in-pad board-wide.

Returns: Dictionary with created rule details.

Note: Creating ComponentClearance, HoleToHoleClearance, BoardOutlineClearance, and other newer rule kinds is not supported on this Altium build because the relevant symbolic constants (eRule_ComponentClearance, ...) are not exposed in DelphiScript. Existing rules of those kinds can be UPDATED via pcb_set_rule_properties (gap_mils field), which dispatches through Rule.RuleKind without needing the symbol.

Input Schema

NameRequiredDescriptionDefault
nameYes
scopeNo
valueNo
allowedNo
max_valueNo
net_scopeNodifferent_nets
rule_typeNoclearance
favored_valueNo
max_uncoupled_lengthNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.6.1

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description carries the full behavioral burden and discloses critical pitfalls: unsupported rule kinds, scope predicates that create never-matching rules, signed solder-mask expansion semantics, default allowed=True behavior, and max_value fallback behavior. These are exactly the behavioral details an agent needs before invoking a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but front-loaded and well structured: purpose first, then parameter guidance, return value, and a critical note. The length is justified by nine parameters and multiple rule-type-specific behaviors, with no wasted filler.

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 absence of annotations, a 0% schema description coverage, and the presence of an output schema, the description supplies all necessary context for correct invocation. It covers parameters, defaults, supported and unsupported rule kinds, scope pitfalls, and return shape without redundantly explaining return values.

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 description coverage is 0%, but the description documents every parameter with per-rule-type meaning, defaults, examples, and edge cases. It adds substantial meaning beyond the bare schema, including default fallbacks, scope expression syntax, and parameter interactions.

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 opens with a precise verb+resource, "Create a new design rule on the active PCB," and immediately enumerates supported rule types so the agent can distinguish the scope from generic rule utilities. It clearly establishes that this is a creation tool for PCB design rules.

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 gives strong usage context through supported rule types, per-type value semantics, and a clear unsupported-kinds note directing agents to pcb_set_rule_properties for updates. It does not explicitly compare against siblings such as pcb_create_diff_pair or pcb_get_design_rules, so the sibling-routing guidance is not fully exhaustive.

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