Skip to content

Add copper query and net tie authoring tools for PCB routing#422

Merged
ecto merged 1 commit into
mainfrom
claude/great-goldberg-zwo2vq
Jul 7, 2026
Merged

Add copper query and net tie authoring tools for PCB routing#422
ecto merged 1 commit into
mainfrom
claude/great-goldberg-zwo2vq

Conversation

@ecto

@ecto ecto commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

Adds three new MCP tools for PCB copper inspection and net tie management, completing the read/write algebra for routed copper and intentional net junctions.

Key Changes

  • get_copper tool — Query the board's routed copper (traces, trace arcs, vias, zones) with optional filters by layer, net, bounding box, and kind. Returns each element with its index (compatible with delete tools) and geometry, enabling surgical edits without exporting the document. Supports pagination with offset/limit (capped at 200 elements per page).

  • add_net_tie tool — Declare intentional junctions between two or more nets (e.g., wye motor neutral points, split-ground stitches, current-sense shunt taps). Supports both board-wide ties and region-scoped ties (position + radius). Validates that all nets exist on the board and rejects half-scoped regions (position without radius or vice versa).

  • delete_net_tie tool — Remove a net tie by index, by matching net set (order-insensitive), or by position (±0.001 mm tolerance). Supports guards: passing nets or position alongside index confirms the indexed tie matches before deletion.

  • Net tie diffing — Extended PcbElementChange to include "netTie" kind and updated diffPcbElements to track tie mutations in the changed diff (ties report their joined nets as "A+B+C" since they have no single net).

  • Copper element bounding boxes — Added copperElementBbox helper to compute conservative axis-aligned bounds for traces, trace arcs, vias, and zones (full-circle bound for arcs to avoid missing copper on bbox queries).

  • Via layer spanning — Added viaSpansLayer to check if a via's barrel spans a given copper layer (e.g., a through via FCu→BCu carries In1Cu).

  • Schema and validation — Added JSON schemas for all three tools with comprehensive property descriptions. Validation includes layer name normalization, net existence checks, and bbox geometry validation.

  • Test coverage — Added comprehensive tests for get_copper (filtering, pagination, index-driven deletes), add_net_tie (board-wide and region-scoped ties, validation), and delete_net_tie (index/net/position matching, guards, DRC integration). Includes an end-to-end test showing that a region-scoped tie exempts a junction short in DRC, and deleting it re-arms the violation.

  • Server integration — Registered all three tools in the MCP server, marked add_net_tie and delete_net_tie as document writers (they mutate the session and must persist/be undoable), and updated the PCB workflow blurb in the server instructions.

Implementation Details

  • Copper queries iterate collections in deterministic order (traces, arcs, vias, zones; index order within each) to ensure offset-paging never skips or repeats elements.
  • Zone outlines can run to hundreds of vertices on dense boards; get_copper reports bbox + vertex count instead of the full outline to keep responses bounded.
  • Net ties are DRC data (not copper geometry) but change what run_drc accepts, so they must persist and be undoable like other mutations.
  • Tie positions are rounded to 0.001 mm on write; delete_net_tie position matching uses the same ±0.001 mm tolerance, so echoing a position from add_net_tie's result always matches.
  • add_net_tie fails closed on a half-scoped region: the kernel's NetTieGroups only forms a region when both position and radius are present, so passing one without the other would silently degrade to a board-wide exemption.

https://claude.ai/code/session_0149H9KjqeyjkVWEihNjMvJS

…-tie tools

Three new MCP tools close the read/author gaps around add_*/delete_*:

- get_copper: the read/query companion to add_trace/delete_trace. Filters
  by layer/net/bbox/kind and returns each trace/arc/via/zone with the same
  per-collection index the delete_* tools accept, so an agent can discover
  copper and drive a surgical delete without exporting the document
  (describe_pcb only aggregates counts). Capped at 200 per page with
  offset pagination and an uncapped total.

- add_net_tie: author an intentional net junction (vcad_ir::ecad::NetTie)
  on the live session — wye/star neutrals, split grounds, and
  current-sense shunts require ties, but only the add_motor_winding
  realizer could write them; hand-building a wye meant offline JSON
  surgery on the saved .vcad. Validates the nets exist, and fails closed
  on a half-scoped region (position without radius would silently become
  a board-wide exemption in NetTieGroups). Returns the updated tie list.

- delete_net_tie: the take-back — by index, or by matching nets (set
  equality) and/or position, with the same index+filter guard semantics
  as delete_trace/delete_via.

Both mutators are registered as doc writers (persisted + undoable), and
undo's changed diff now reports netTie churn. Server instructions grow a
"surgical copper edits" sentence in the PCB workflow blurb.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0149H9KjqeyjkVWEihNjMvJS
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vcad-mcp Building Building Preview, Comment Jul 7, 2026 2:11pm
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
mecheval Ignored Ignored Jul 7, 2026 2:11pm
vcad Ignored Ignored Jul 7, 2026 2:11pm
vcad-docs Ignored Ignored Jul 7, 2026 2:11pm

Request Review

@ecto
ecto merged commit 630fb1c into main Jul 7, 2026
12 checks passed
@chojiai

chojiai Bot commented Jul 7, 2026

Copy link
Copy Markdown

What shipped

Three new tools are available for PCB work in this release.

  • You can now inspect all routed copper on a board — traces, vias, and poured zones — filtered by layer, net, area, or type, without exporting the full document. Each result includes the exact identifier needed to delete that element directly.
  • You can declare intentional connections between two or more nets (for example, a motor's star-point neutral, a split ground, or a current-sense shunt) so the design-rule checker recognizes them as deliberate rather than flagging them as shorts. Scoping a tie to a specific location keeps the checker strict everywhere else on the board.
  • You can remove a declared net tie by index, by the nets it joins, or by its position, restoring the short violation if the copper is still there.

Plain-English summary generated by Choji from this pull request.

ecto pushed a commit that referenced this pull request Jul 7, 2026
add_net_tie / delete_net_tie (merged from main, #422) postdate the
drc_delta contract but mutate DRC semantics directly: a tie exempts
short/clearance findings at a junction, and deleting one re-convicts
the junction copper as a live short. Wrap both in the same
before/after capture — a region-scoped tie snapshots its circle,
a board-wide tie snapshots the whole board.

add_net_tie on an intended junction now reports the short it resolved
(clean, resolved >= 1); delete_net_tie reports the short it exposed
(clean: false, shorts >= 1). Tested with the symmetric
short -> tie -> untie round trip.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WMn4sMTRARjMBJxMgewqt
ecto added a commit that referenced this pull request Jul 7, 2026
#438)

* feat(pcb): verify-on-write drc_delta on every copper-mutating MCP tool

Field report: add_motor_winding returned a bare document_version for a
board it had just shorted in 3 places and islanded in 3 more — the agent
only learned from a separate run_drc. Every copper mutator now wraps its
mutation in a before/after DRC snapshot and self-reports what it
introduced.

- Extract the route_nets receipt diff core into a shared helper:
  diffViolations (multiset identity, @vcad/core receipt engine) +
  drcDelta(before, after) in the MCP ecad tools — introduced/resolved
  counts, categories (shorts/clearance/connectivity/manufacturing), a
  worst-first capped sample with positions, and `clean` to branch on.
- Attach `drc_delta` to add_trace, add_via, add_via_array, add_coil,
  add_coil_array, add_motor_winding, delete_trace, delete_via,
  delete_zone, set_board_outline, and set_stackup (verified no-op).
  Composite tools capture once around the whole batch.
- Incremental scope: boards with >= 2000 elements snapshot via a new
  bbox-scoped kernel entry point check_drc_in_region (vcad-ecad-pcb),
  which filters the geometric checks' subjects to the mutation's
  inflated bbox while connectivity (shorts/islands) stays board-global —
  behind a region parameter on the existing rule logic, not a fork of
  it. Exposed as ecadCheckDrcInRegion in kernel WASM with a full-DRC
  fallback for stale artifacts.
- kernel-wasm build: re-canonicalize glue call sites that wasm-bindgen
  aliased onto a merged twin's export name (LLVM ICF), so the
  glue-drift gate keeps meaning "mis-wired" rather than "rebuilt with a
  newer rustc". Rebuilt artifacts include the new binding.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WMn4sMTRARjMBJxMgewqt

* chore(mecheval): cache leaderboard SVG rendered during workspace build

The leaderboard build step renders any run .vcad missing from the
checked-in SVG cache; this one (f3-clip-pipe-01 / wafer-direct-GLM-5.2)
had never been cached.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WMn4sMTRARjMBJxMgewqt

* feat(pcb): extend verify-on-write drc_delta to the net-tie tools

add_net_tie / delete_net_tie (merged from main, #422) postdate the
drc_delta contract but mutate DRC semantics directly: a tie exempts
short/clearance findings at a junction, and deleting one re-convicts
the junction copper as a live short. Wrap both in the same
before/after capture — a region-scoped tie snapshots its circle,
a board-wide tie snapshots the whole board.

add_net_tie on an intended junction now reports the short it resolved
(clean, resolved >= 1); delete_net_tie reports the short it exposed
(clean: false, shorts >= 1). Tested with the symmetric
short -> tie -> untie round trip.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WMn4sMTRARjMBJxMgewqt

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants