---
name: eda-portal
description: Operate and debug PCBFlux, the Cogniviz.ai EDA portal (pcbflux.com), through its MCP server. Use for any task on a KiCad project in the portal - create or import a board, edit schematic or PCB, run DRC/ERC, autoroute, set design rules, make a BOM with DigiKey/LCSC sourcing, export fab files - and for diagnosing and fixing the errors those tools return.
---

# EDA portal over MCP

The portal keeps each project's KiCad files (`.kicad_sch`, `.kicad_pcb`, `.kicad_pro`) in its own store with numbered revisions. Every tool works on that store, never on a local checkout. This skill is about KiCad projects only. Never write or edit a `.circuit.tsx`, and do not look for TSX tools: `autoroute`, `rerun_export`, `create_source_upload` and `import_circuit_source` no longer exist (use `kicad_autoroute`, `kicad_import_zip`). Config JSON (analysis, sim, bom, intent, rules) is the only thing `write_file` is for.

## Connect

- `https://pcbflux.com/mcp` (Railway). Claude Code: `claude mcp add --transport http pcbflux https://pcbflux.com/mcp`, then `/mcp` and Authenticate (AuthrzMe, `@cogniviz.ai`). The Cloudflare site `eda.cogniviz.ai` was retired on 2026-11-25.
- Machine tools run on runners: ERC, DRC, `kicad_fab`, SPICE and `kicad_edit` on the always-on runner; `kicad_review` and `kicad_build` (schematic edits), `run_em`, Freerouting and plane taps only while a Docker machine (desktop or VM) is enrolled and online. Without one they answer 503 or "no runner": say what is blocked, do not work around it.
- Every tool with its arguments: `reference/tools.md` next to this file, made from the server's own tool table. Install or update this skill and the others: `curl -fsSL https://pcbflux.com/skills/install.sh | bash` (rewrites only what changed; run it after the tools change).
- Scripts: a personal access token from the portal page `/settings/mcp` as `Authorization: Bearer <token>`. Tokens carry read, write or manage permission and may be limited to projects; project roles (viewer, editor, owner) still apply.
- KiCad-only address `<site>/mcp/kicad` (Streamable HTTP like `/mcp`): just the KiCad tools, project passed per call. Use it for a KiCad client that needs nothing about sourcing.
- Scoped address `/mcp/<project>` or `/mcp/<project>/<circuit>` limits a connection to one project or circuit.
- Never print a token. Do not paste it into files in a repo.

## First moves

0. New board: `create_project {name}` (template `kicad-blank` is the default: empty schematic, board and project, no TSX). Then add parts with `kicad_build` `sch_*` tools (see the tool map).

1. `list_projects` to find the project id (looks like `name-ab12`). Pass it as `project` everywhere. A project may be listed under an organisation (`organisation` in the result): that is grouping only, it changes no access and is managed on the portal's projects page.
2. `kicad_list {project}` shows files and their `rev`. A circuit is the folder name, e.g. `fido2-key/fido2-key.kicad_pcb` is circuit `fido2-key`.
3. `get_project`, `get_rules`, `list_nets {project, circuit}` before changing anything. `get_project` also returns `links` (linked GitE2E repos, Designs CAD models, and stale/drift counts); inspect details with `list_project_repos`, `list_commit_links`, and `list_project_designs`.

For a whole board from requirements to fab, or when the user asks for a change, follow the `design-to-fab` skill (ordered gates and a change-impact table); this skill is the tool reference.

## Linked repositories, commits, CAD designs & assets

PCBFlux is the hub for the hardware product:
- **What lives in PCBFlux**: schematics, PCBs, evaluations, BOM/sourcing, Fab Gerbers/CPL, component `datasheets`, `board_datasheet`, and PCB-related `project_assets` (including generated product datasheet PDFs and synced CAD snapshots).
- **What lives in GitE2E (`platform.gite2e.com`)**: firmware, host software, test harnesses, and editable documentation/datasheet sources. Link one or more repos per project with `link_repo {project, repo_url, role}` (`board`, `firmware`, `host`, `tests`, `docs`, `other`; optional `subpath` for monorepos).
- **Commit verification**: Never assume a code/doc commit matches the board without verifying it on the server. Call `verify_commit {project, repo_id, commit_sha, expect_paths?}` (checks via the user's connected GitE2E OAuth account; returns `verified` for agent-enabled repos or `metadata_only` for E2EE-only repos when the SHA sits on a branch/tag head) and `link_commit` to record the association and snapshot current KiCad file revisions (`list_commit_links` flags `stale: true` if `.kicad_sch`/`.kicad_pcb`/`.kicad_pro` change later).
- **What lives in Designs (`designs.cogniviz.ai`)**: parametric enclosures, brackets, and fixtures. Link them with `link_design {project, design_id, role, pinned_version?, signed_view_url?}` (sealed at rest and opened through PCBFlux RBAC), check version/board drift with `verify_design_links`, and snapshot STEP/STL/PNG exports into PCBFlux `project_assets` with `sync_design_asset`.

## The process (follow it in this order)

1. **Look.** `list_projects`, `kicad_list`, `get_rules`, `list_nets`. Note each file's `rev`.
2. **Design time.** Before routing, `prepare_analysis {project, circuit}` so power and thermal have rails and specs; read its `estimated_specs` and report them as unverified.
3. **Edit small.** One cause per change. `kicad_edit` with `dry_run:true` first, then for real; schematic edits with `kicad_build`. Whole files only with `kicad_put` and the `base_rev` you read.
4. **Route.** Planes first (`add_zone`, `refill_zones`), then `kicad_autoroute` with `require_complete:true`. The router does not know inner planes: a supply pad that relies on a plane still needs its own short F.Cu stub and a via (`add_track` + `add_via`, 0.6 / 0.3 mm), placed clear of neighbouring tracks.
   - **Manual routing** (instead of or before the autorouter, or to close what it left): `kicad_ratsnest {project, circuit}` lists every open connection as text (pad to pad with x, y, shared layers, `needs_via`, and the net's width, clearance and via size). Route them with `kicad_edit` `route_pads {from: "U1.3", to: "R2.1"}` (pad centres looked up, 45 degree bends, net-class width, a via near the far pad when the layers differ; `waypoints` to steer around parts, `via: [x, y]`, `layer`/`to_layer`). Before drawing, `kicad_route_plan` finds the way (text, no KiCad run): mode `path` gives the corner points and a ready `add_track` op around other nets' copper, or says which end is walled in and by what (`walled_in_by`); mode `via_spots` lists where a via fits near a point, and with `escape_from: "U1.3"` the short breakout track to each. Pass ops you plan (or removals) as `after_ops` to plan a sequence before saving any; route the net with the fewest options first. A pad with no breakout: mode `ripup` says what to remove (a net's copper near the pad, or one via) and which nets to route again. A differential pair: mode `pair` with both nets' via ends routes them side by side on one layer and gives `skew_mm`; `crosses: true` means the vias sit on the other sides at one end, so move one end's vias first. Try a batch with `precheck: "only"` first: it costs no KiCad run, and its `precheck.conflicts` (other net, gap and need in mm) and `loose_ends` show what to move. Then send the same ops (with `run_drc` last) and read `open_connections_estimate {before, after}`. Use pictures (`kicad_copper_view`) once per stage, not per net: they cost far more than the text. Parts a person placed or tracks they drew in the designer stay; the autorouter keeps them too.
5. **Check after every edit.** `kicad_drc` (about 3 s) and read counts: errors, unconnected, warnings by type. Then `kicad_erc`, `verify_design`. After placement and after routing, `check_layout` (seconds, no DRC): layout practice in three groups, placement (functional grouping, decoupling within 5 mm, heat and EMI keep-away), routing (corners, detours, stacked parallel runs on adjacent layers, sensitive nets beside switch/clock nets, pair skew and differential impedance (`rules.json diff_pairs[].ohm`), thermal relief, edge clearance (`layout.edge_clearance_mm`, default 5 mm for boards in rails), planes, a test point per rail) and width (signal 0.2 mm+, power 0.3 mm+ and IPC-2221 for the current, IPC-2221B spacing above 30 V). It never repeats a DRC limit. For nets: `kicad_netlist` is the real netlist (use it, not `list_nets`/`get_components`, to say which net a pin is on; a wire drawn over a pin connects nothing), and `kicad_net_diff` compares it with the board's pad nets (missing labels, sheet-local labels, merged nets) after label or sheet edits. Thresholds go in `<circuit>.rules.json` `layout`; currents and voltages come from `<circuit>.analysis.json`.

- **Labels by pin, not by coordinate.** Use `kicad_sch_labels` (`label_pin {ref, pin, net}`, `globalize {nets}`, `rename_net {from,to}`) instead of `sch_add_label` with x/y: it places the label exactly on the pin end and re-reads KiCad's netlist (`verify`, `nets_joined`). Find what needs a label with `kicad_net_diff`; a net split across sheets usually needs `globalize`.
- **Edits that must not make DRC worse.** `kicad_edit` with `max_new_errors: 0` refuses the save if DRC gets worse; `set_track_width {net, width, fit: true}` finds the widest width that fits. `kicad_autoroute` `net_widths {"+3V3": 0.6}` sets power-net widths (TraceMaker widens towards them after routing; Freerouting routes at them).
6. **Parts.** `lookup_parts`, then `digikey_search` and `set_sourcing`, then `make_bom`. Stock and price come from the supplier tools, never from `search_components`.
7. **Report** the new `rev`, the DRC counts, and what is still estimated or unverified. A board is done only at 0 errors, 0 unconnected.

## Tool map (KiCad projects)

| Job | Tool |
|---|---|
| Read / write whole files | `kicad_read`, `kicad_put` (needs `base_rev`), `kicad_list`, `kicad_revisions`, `kicad_restore` |
| Archiving & circuit versions | `archive_project`, `archive_circuit` (reversible per-circuit archive); `list_circuit_versions`, `create_circuit_version` (**always ask the user explicitly for `tag` first—never auto-generate or guess it**), `revert_circuit_version` (`dry_run: true` first, then `confirm` = `tag`), `delete_circuit_version` (owner, label only) |
| Import | `kicad_import_zip` (a board zip), `kicad_import_exports` |
| PCB edits (no code) | `kicad_edit` ops: `add_footprint`, `update_footprint` {lib,name,refs?} (board parts from the project library again: keeps place, angle, side, value, nets), `set_pad_nets`, `remove_footprint`, `set_outline`, `move_footprint`, `flip_footprint`, `set_field`, `set_net_class`, `add_track`, `remove_track`, `add_via`, `add_zone`, `remove_zone`, `add_keepout`, `set_silk_text_size`, `refill_zones`, `run_drc` |
| Schematic edits | `kicad_build {project, path, tool, arguments}` (the key is `arguments`) with `sch_add_symbol {library, symbol_name, reference, value, x_mm, y_mm}`, `sch_add_wire {x1_mm, y1_mm, x2_mm, y2_mm}`, `sch_add_label {name, x_mm, y_mm}`, `sch_add_power_symbol`, `sch_update_properties`, `sch_delete_symbol`, `sch_annotate`, `sch_build_circuit`, `lib_assign_footprint {reference, library, footprint}`. Wire ends must land on pin ends (grid 1.27 mm) |
| Schematic to board | (If the result has `duplicate_refs`, parts are on the board twice: run it again with `remove_duplicates: true`, dry_run first. `check_placement` fails on the same fault.) `kicad_sync_pcb {project, circuit, force?, dry_run?, outline?:{width,height}, origin?, remove_orphans?}` adds footprints for parts the board lacks and sets every pad's net (the Update PCB from Schematic step). Run it after the schematic has footprints assigned; then place with `kicad_edit move_footprint`. Raw ops `add_footprint`, `set_pad_nets`, `remove_footprint`, `set_outline` exist in `kicad_edit` |
| Checks | `kicad_drc` (about 3 s), `kicad_erc` (about 5 s even for 170+ parts, follows sub-sheets; use it instead of `kicad_review run_erc`, which stops at 150 s on a big sheet), `kicad_review` with `run_erc` / `run_drc` / DFM tools, `verify_design`, `check_placement` |
| Routing | `kicad_autoroute` (Freerouting, VM job) |
| Footprints and cleanup | `kicad_footprint_create {project, library, spec:{name, pads:[{number,x,y,w,h,type,shape,drill}]}}` makes a missing footprint into `_libs/<library>.pretty/` (set the schematic Footprint field to `<library>:<name>`, then `kicad_sync_pcb`); check pad positions against the maker's drawing. `kicad_delete {project, path, base_rev}` removes a leftover file (restorable with `kicad_restore`; refuses root files) |
| First-cut board | After `kicad_sync_pcb` (use `skip_missing:true` to place every part that has a footprint and list the rest under `missing_footprints`): ONE `kicad_edit` with `set_outline` + `place_footprints {parts:[{ref,x,y,angle?,side?:"F"|"B"}]}` (up to 1000 parts, ops limit 500) places the whole board. `side:"B"` flips a part to the bottom, which mirrors its pads: dry-run first and look for new shorts (a two-pad part is put right by turning it 180 degrees). Plan it from the board text (`kicad_read`: courtyard sizes) and the nets (`list_nets`): group parts by function, pack courtyards with about 0.7 mm gap, keep sockets near the edge. Then fine-tune with `move_footprint`, `add_track`, `add_via`, `add_zone`, `refill_zones`, `run_drc` in dry runs |
| Design criteria | `get_rules`, `set_rules` (rules are mirrored into the project's `.kicad_pro`, which DRC and the router use) |
| Parts and cost | `lookup_parts`, `set_sourcing`, `get_sourcing`, `make_bom` (`csv:"digikey"` for DigiKey), `digikey_search`, `mouser_search`, `element14_search`, `get_offers` |
| Find a component | `search_components` (MPN, LCSC number or description words; package, category, basic_only), `get_component` (record, alternatives, our datasheets). Also alone at `https://pcbflux.com/mcp/components`. No stock or price: use `digikey_search`, `search_suppliers` or `get_offers` for those |
| Fab output / source zip | `kicad_fab` (gerbers, drill, position file, IPC-D-356), `download_circuit_source` (zip of the circuit folder) |
| Look at the fab files | `kicad_fab_preview {project, circuit, view?: top/bottom/<layer>, box?}` draws the Gerber and drill files of the latest `kicad_fab` zip and lists checks (outline open, pads in the outline file, copper outside the board, silkscreen on pads, missing files). Look at top and bottom before any order. |
| Vias and outline | `kicad_edit` `set_outline {x,y,width,height,corner_radius?}` or `{polygon,corner_radius?}`; `via_array {ref,pad,pitch,diameter,drill,protection?}` for heatsink vias in an exposed pad; `stitch_vias {net,where:zones/edge/polygon,pitch,diameter,drill}` then `refill_zones`. `protection`: tent, plug, fill (via-in-pad), open. |
| Simulate the board | `simulate_board {project, circuit, view: power/copper/heat, load?: typical/full, net?, show?: drop/current, layer?, px?, image?}`: the Simulate page's answers from the power estimate. `power`: supplies, regulators (in, out, loss, efficiency), rails with their feeder, loads per part, at typical and full load. `copper`: every rail that carries current solved through its copper in one run (sources at the regulator, inductor or connector; loads from the estimate), worst drop and loss per rail, rails it could not place in `skipped`. `heat`: board temperature from each part's estimated power, next to what its package alone would reach. Estimates; copper and heat take 10 to 60 s |
| Copper checks | `check_zones` (islands, necks, starved pads, fast nets over plane gaps), `check_voltage_drop {net, sources:[{ref,pad?}], loads:[{ref,current_a}], rail_v?}`, `run_board_thermal {parts?:[{ref,power_w,theta_jb?}]}` (sees copper and vias; says what the vias are worth). All estimates on a grid. |
| See the copper | `kicad_copper_view {project, circuit, view?: all/stack/layers/<layer>, color_by?: net/class/width, highlight?: [nets], box?}` returns a picture: use `highlight` to follow one net through the layers (stack view draws its vias between layers), `box` to zoom, and read mm coordinates off the axes of a one-layer view for `kicad_edit`. The copper checks take `image: true` or `{view, show, box, scale}`: `check_zones` marks floating pieces (F), necks (N), unserved pads (P) and plane gaps (G); `check_voltage_drop` shows drop or `show: "current"`; `run_board_thermal` shows the heat map (`view: "stack"` for all layers in 3D). Marks are listed with coordinates in the result. Pass the same `scale` to compare before and after a change. |
| Stackup | `kicad_edit` `set_stackup {preset: jlc_2layer_1.6mm / jlc_4layer_1.6mm / jlc_6layer_1.6mm / jlc_8layer_1.6mm, finish?: ENIG/HASL/HASL lead-free/OSP}` writes the board's physical stackup (JLCPCB figures, approximate: check the fab's current stackup); the copper count must match (`set_copper_layers` first). Then `get_board_stackup` and the impedance checks read it |
| Look at it | `get_3d_image`, `get_board_stackup`, `add_3d_part` / `list_3d_parts` / `remove_3d_part` (visual parts) |
| What a tool offers | `kicad_tools` lists the allowed `kicad_review` and `kicad_build` tools (only tools the KiCad server really has) |
| Read-only KiCad checks | `kicad_review {project, path, tool}` e.g. `run_erc`, `sch_get_symbols`, `sch_get_connectivity_graph`, `pcb_get_board_summary`; `path` is the file (`.kicad_sch` for ERC and schematic tools, `.kicad_pcb` for board tools) |
| Functional check | `check_requirements {project, circuit}` against the requirements saved with `set_design_spec` (kept in the database; `get_design_spec` reads them with the context and gate history; `get_checklist` / `set_checklist` track the 12 gates) (parts, links, firmware/debug port, test access, antenna pitch, config files; pass, fail, deferred, needs_human). A `manual` item stays needs_human until the user confirms it: then `confirm_requirement {project, circuit, id, note}` records who and when (it lapses when the schematic or board is saved again, unless `holds: "text"`). Never call it without the user's say-so |
| Peak load | In `<circuit>.sim.json` a sweep case takes `"peak": true` (every chip at its spec's `i_peak_ma`) or `"load_ma": {"U1": 345}` (single chips, mA): assert rails, regulator headroom and input current in that case. `analyze_circuit` counts the load behind a fuse, ferrite or shunt in the rail before it when both rails have a voltage and the input rail is under `sources` |
| Schematic by part and pin | `kicad_sch_labels` ops: `label_pin`, `no_connect`, `remove_no_connect`, `remove_label`, `remove_wire`, `remove_power_flag`, `globalize`, `rename_net`, `labels_to_power {nets: "power"}` (rail labels become power symbols), `power_flag {net}`, and `pin_names {ref, pins: {"3": "CE"}}` for a part drawn with a pin-compatible symbol of another part (check pin numbers on the datasheet first) |
| Is it a drawing? | `check_schematic {project, circuit}` (milliseconds, read-only): wires, labels and power symbols per part, rails drawn as labels, off-grid, dangling labels, overlaps, paper and title block, visible supplier fields. A label on every pin and no wires is `label_dump` (fail): draw it instead |
| Draw it as blocks | `kicad_sch_blocks {project, circuit, blocks: [{motif, parts, nets, title}]}` redraws parts as pre-wired blocks (decoupling, ldo, divider, pullup, led, rc_filter, crystal) with power symbols and headings; the netlist must not change or nothing is saved (`dry_run` first). `kicad_sch_view {project, path or page}` draws a sheet as KiCad does: look at it after every schematic change |
| Build progress | `get_build {project, circuit}`: the 13 build steps (`open` / `built` / `blocked`) and `next`. `set_build_step {project, circuit, step, status, note}` marks one; built is progress, not a verdict |
| Evaluation (the verdict) | `run_evaluation {project, circuit}` starts every check on the board as it is and returns an id at once; `get_evaluation` gives `status`, `verdict` (`pass` / `fail` / `incomplete` / `waiting`), each check, `outdated` and `affected` after a later save, and `current` (passed and not outdated). `kicad_fab` works only when `current` is true |
| All checks, one verdict | `run_tests {project, circuit}`: requirements, intent, kept EM solve, ERC, net diff, DRC and sim.json assertions as stages `pass` / `fail` / `unknown` / `skipped`. `unknown` (could not run, not written, needs a person, stale, out of time) blocks like `fail`; fix it or defer its gate with a reason (`set_checklist`). `only: [stages]` re-runs a subset. `suggest_tests {project, circuit}` drafts sim.json assertions (rails, dividers) with their basis; review, then `write_file` them |
| Simulation and thermal | `run_simulation` (ngspice, needs rails in `<circuit>.analysis.json`; each declared rail gets a 5 % band check), `run_sweep`, `analyze_circuit`. A rail a chip makes itself (MCU VCAP, a secure element's VOUT) needs `internal_rails {pin: volts}` in the chip's part spec (or sim.json `internal_rails {ref: {pin: volts}}`), else it floats; a net the model cannot judge goes in sim.json `not_checked {net: why}`. `run_thermal`: parts steady-state for everything, LED transient for power LEDs only (datasheet current above 30 mA; `leds: "all"` in thermal.json to force) |
| Manufacturability | `check_dfm {project, circuit, profile?: standard/hdi, limits?}` measures narrowest track, closest gap, vias and rings, drills, copper to edge, silk text, layer count, HDI vias and fiducials against the fab limits in `<circuit>.rules.json` `dfm` (then `board`, then the profile). Put the chosen fab's figures in `rules.json dfm`; the profiles are generic. It closes checklist step 8.2 on a pass |

## Rules for every write

- Files have revisions. A write with a stale `base_rev` returns `{saved:false, conflict:{current_rev}}` and changes nothing. Re-read, then retry with the new `rev`.
- `kicad_edit` runs ops in order and stops at the first failure; nothing is saved then. Use `dry_run:true` to test. Up to 200 ops per call.
- Coordinates are mm, KiCad style (y points down). Layers: `F.Cu`, `In1.Cu`, `In2.Cu`, `B.Cu`.
- Tool input is data only. Do not try to run code through the portal.
- Estimates (power, thermal, part specs, supplier numbers) are approximate. Say so; do not present them as verified.
- The BOM tool never places orders. It produces files and links.
- Do not delete files, revisions or projects unless the user asked.
- Never auto-generate or guess a circuit version tag when calling `create_circuit_version`: always ask the user explicitly what version tag they want first.

## Workflows

**New board from a netlist or zip.** `create_project` (default template `kicad-blank`: empty schematic, board and project), then build the schematic with `kicad_build` `sch_*` tools, assign footprints (`lib_assign_footprint`), `kicad_sync_pcb` with an `outline`, place with `kicad_edit`, route. Or bring a board with `kicad_import_zip` / `kicad_put`. Run `kicad_review run_erc`, fix, then `kicad_drc`.

**Place, then route.**
1. Move parts with `kicad_edit move_footprint`. Keep courtyards 0.25 mm apart or more and keep parts inside the outline.
2. For a 4-layer board set the layer count in the board file, then `add_zone` GND on `In1.Cu` and the main supply on `In2.Cu` with the outline polygon inset 0.3 mm, then `refill_zones`.
3. `kicad_autoroute {project, path, time_limit_s:1800, require_complete:true}`. The default engine is TraceMaker, a GPU router on the organisation's router machine (503 when none is online): it routes differential pairs as pairs and critical nets first, drops plane-net vias into the zones, and keeps existing copper. Set the project's net classes to the real minimums first (a fine-pitch part needs a via that fits its pitch). On a dense board that runs out of memory pass `pitch_um: 50`. `engine:"freerouting"` (with `max_passes`) runs on the service machine instead. The reply's `router_summary` lists what stayed open and why. It is a job: when the answer is `{status:"running", job, base_rev}`, call again with the same `job` and `base_rev` until it finishes. Routing is not deterministic, so retry when `require_complete` refuses to save.
4. `kicad_drc {project, circuit}`. Aim for 0 errors and 0 unconnected.

**Design rules.** `set_rules` writes net classes and board limits into `.kicad_pro`; `get_rules` reads them back. Change rules, then re-run DRC, because old routing may violate new clearances (re-route).

**BOM with sourcing.** `lookup_parts {project, circuit}` fills LCSC numbers; DigiKey India by MPN: `digikey_search`, then `set_sourcing` by `refs` or `part_key`, then `make_bom`. Check stock 0 rows before quoting prices. Test points and board-edge connector fingers are not parts: exclude them.

## How long calls take

Use these to set expectations and to tell a slow call from a stuck one. Figures are measured on a small 2-layer board (30 parts) unless a range is given; a dense 4-layer board is several times slower. An admin gets the live figures per endpoint from `GET /api/jobs/stats?days=7` (median, 90th percentile, longest, queue wait).

| Call | Typical | Runs where | If it takes much longer |
|---|---|---|---|
| `get_*`, `list_*`, `kicad_list`, `kicad_read`, `pcb_query`, `kicad_ratsnest`, `kicad_route_plan`, `kicad_edit precheck:"only"`, `set_rules`, `write_file` | under 1 s | web service | retry once; then a service fault |
| `check_placement`, `check_layout`, `check_dfm`, `check_intent`, `kicad_net_diff` | under 1 s | web service (no runner) | same |
| `kicad_erc`, `kicad_drc`, `kicad_footprint_audit`, `kicad_netlist` | 2 to 5 s | runner, kicad | look at `GET /api/jobs`: queued means no free runner slot |
| `kicad_edit` | 3 s median, 7 s at the 90th percentile, 40 s at worst (93 calls, week to 2026-11-26); add one DRC run (2 to 5 s) with `max_new_errors` or a `run_drc` op | runner, kicad | split the ops; a board over the edit size limit is refused, not slow |
| `kicad_copper_view`, `kicad_fab_preview`, `get_3d_image` | 2 to 15 s | runner, kicad | smaller `px` or a `box` |
| `check_zones`, `check_voltage_drop`, `run_board_thermal` | 3 to 40 s (KiCad refill plus a grid) | runner, kicad | fewer nets per call; coarser grid |
| `run_simulation`, `run_sweep` | 1 to 10 s; `run_montecarlo` up to about 1 min | runner, sim | fewer cases or runs |
| `kicad_sync_pcb`, `kicad_build` tools | 3 to 5 s measured (11 calls); up to 30 s on a large schematic | routing machine, kicad-mcp | 503 means that machine is offline |
| `kicad_autoroute` | 1 to 15 min as a job: the call returns `status: "running"` with `job`; call again with `job` and `base_rev` about once a minute | routing machine, route | never start a second job; 429 means one is running |
| `run_em` | 1 to 20 min as a job | routing machine, em | lower the mesh budget |
| `kicad_fab` | 10 to 40 s | runner, kicad | |
| `run_evaluation` | 15 s to 2 min for all 12 checks; poll `get_evaluation` | web service plus runner | a check `could_not_run` or `time_budget` means run it again |
| `make_bom`, supplier searches | 2 to 20 s (outside services) | web service | a supplier may be rate-limited: say so, do not loop |
| an agent step (build, repair) | 3 to 10 min and about 3 to 5 USD at list prices per run (`get_evaluation` `repair_cost` has the measured median) | runner, agent | it stops at the admin's cost limit and says so |

A request that is cut at about 170 s (HTTP 502 or 504) was a job that ran past the request time: do not send it again as it was; use the job form or make the call smaller.

## Fewer calls

Each tool call is a model turn that re-reads the whole conversation, so the number of calls is the cost, not the protocol.

- **`batch_read {project, calls: [{tool, args, pick?, max_chars?}], max_chars?}`**: up to 12 read tools in one call. Use it whenever you would call the same read several times (`pcb_query` per net or box, `get_part_spec` per part, a supplier search per BOM line) or want a set of checks together (`kicad_drc` with `summary_only`, `check_layout`, `check_zones`, `check_dfm`). Answers come back as text cut at `max_chars` (default 4000, up to 20000); `pick: ["verdict", "counts"]` keeps only those top-level fields of a JSON answer. A failed call gives its error and the others still run. Time is the sum of the inner calls.
- Not batchable: anything that writes, pictures (`kicad_copper_view`, `get_3d_image`, `kicad_fab_preview`), download links, long jobs (`kicad_autoroute`, `run_em`). Call those directly.
- Writes already batch: `kicad_edit` takes up to 200 `ops` in one call. Send one call with all ops for a region, not one call per track.
- A whole board file is often over the 2 MB limit of `kicad_read` and stays so at every revision: do not retry it. `pcb_query` (by `refs`, `nets`, `bbox`, `kinds`) reads the part you need; `kicad_get_url` gives a download link.
- Ask for less: `summary_only`, `box`, `nets`, `limit` where a tool has them. A long answer is re-read on every later turn.
- The portal's own agent can, when an admin sets `agent_code_calls` to `read` (`set_setting`, default `off`), run read tools from a script in the model provider's code sandbox: a loop of reads is then one model turn and only the script's printed output enters the conversation. Writes are never callable from a script. Board data that passes through the sandbox is kept by the provider for up to 30 days.

## Models and cost

The top model (Fable) runs only during a board's build chain. A repair run, a single checklist step started alone and the planning agent take the "hard" tier's model (`agent_model_hard`, Opus 5.5 by default). One run ends at `agent_budget_cents` (default 500). A run that errors does not save its cost.

## Repair without waste

A repair agent run costs about as much as a build step, so start one only on what it can move.

1. `get_evaluation` and read `repair`: every check that did not pass has `who` (`agent`, `person`, `rerun`, `build`), `why` and `tries`.
2. `agent`: a repair run works on these (`POST /p/<id>/agent` with `item: "fix"`, or the Repair button). It gets each check's pass rule and first findings.
3. `person` with `tries` above 0 is **manual repair**: a run already worked on it and the result did not change, or two runs did not clear it. Do not start another run as it was. Either fix it by hand (guarded `kicad_edit` with `dry_run`, then `max_new_errors: 0`), or give the agent a concrete instruction (`keys: [check]` with `note`): which part to move, which footprint to use, which limit the fab allows.
4. `person` with `tries` 0 is a decision or a confirmation (a requirement, whether the board has an antenna): ask the person; never guess it.
5. `rerun`: the check's tool failed; run the evaluation again. `build`: the board has no parts; the build comes first.
6. After any fix, run the check's own tool, then `run_evaluation`. Report cost and which checks closed.
7. Only a run that changed something counts as a try: one that only read (cut off, or failed) leaves the check with the agent. A repair run starts the evaluation again when it ends; a restart of the web service cuts a running evaluation off (`interrupted`), so run it again before the next repair.

Fixing by hand is often cheaper than a run for: one net over a plane gap, a part too near the edge, a track under its class width, a single DRC error. Use a run for work with many similar findings (routing leftovers, many pours, many footprints).

## Part against footprint

`check_part_footprint {project, circuit}` compares, per BOM line, the LCSC part that will be bought with the footprint on the board: chip size, package family (SOT-25 is SOT-23-5), pin count against pads, and body size against the span of the pads. `mismatch` must be settled before fab files: another part (`set_sourcing`) or another footprint (the symbol's Footprint field, then `kicad_sync_pcb`). `check` means the names cannot tell: read the footprint (`kicad_edit` op `read_footprint`, or `pcb_query` by ref) and compare its pads with the maker's drawing (`get_datasheet_page`). A `match` is by name only, not a land-pattern check. Run it after sourcing and before `kicad_fab`.

### Swapping a footprint to fit the bought part

Do it in this order; each step was needed on a real board (ta-sensor, 2026-11-26):

1. Pads of the bought part: pcbparts `jlc_get_pinout {lcsc, footprint: true}`. A stock KiCad footprint named after the part is best (`update_footprint {lib: "Connector_USB", name: ...}` works for stock libraries too); otherwise `kicad_footprint_create` in the project library from those pads.
2. `kicad_edit update_footprint {lib, name, refs: [one ref]}`, `dry_run` first: read `pads_kept`, `pads_added`, `pads_removed`. One footprint per call.
3. The pads have moved, so tracks end in the air or on the wrong pad. `pcb_query {refs, kinds: ["footprints"]}` for the new pad positions, `pcb_query {bbox, kinds: ["tracks", "vias"]}` for what is there (each has an `id`), then one `kicad_edit` with `remove_track {id}`, `add_track`, `add_via`, `refill_zones` and `max_new_errors: 0`. Pads the old footprint joined inside itself (a 4-pad switch replaced by a 2-pad one) now need a track between the two track ends.
4. Set the schematic's Footprint field to the new name (where `kicad_build` is missing: `kicad_read` the `.kicad_sch`, replace the old `lib:name`, `kicad_put` with `base_rev`). Then `kicad_footprint_audit` must show no `footprint_swaps`.
5. `kicad_drc`, `check_zones`, `check_part_footprint`, then the evaluation.

A pad the pour reaches with one spoke only (`starved_thermal`), hemmed in by its neighbours: tie it with a track to a pad or via of the same net and keep the pour off it with `add_keepout {polygon, layers, no_copper: true}`. `check_zones` then lists it as low `zone-pad-track-tied`; check the track's width against the pad's current.

### Checking a 3D model against its footprint

`get_3d_image {project, circuit, source: "kicad", refs: ["J12"], camera: "top-down-ortho"}` renders a close view of those parts only (4 mm around their pads; `box: [x0, y0, x1, y1]` for an area). Look from `top-down-ortho` for x/y offset and rotation, from `front` or `left-sideview` for height and pins through the board. The close view has no zones and its outline is the area's edge. Fix an offset with `kicad_set_3d_model` (offset, rotate) on the footprint. The whole-board view leaves out inner-layer zone fills on large boards; the reply says so.

## Reading DRC

`kicad_drc` with `summary_only` gives `by_type`: per finding type the count, two examples and `fix`, one line on what clears that type and with which tool. Work the type with the most findings from one cause first. Silkscreen types are warnings that do not block fabrication; say so and move on unless the person wants them clean.

## Fab limits

Name the fab once, in `rules.json` `dfm` (`set_rules`): `{ dfm: { fab: "JLCPCB" } }` picks the profile `jlcpcb_2l` or `jlcpcb_multi` by layer count (JLCPCB's published rigid FR-4 minimums on the date in the profile label). `check_dfm`, the build steps and the evaluation then measure against the same sheet. For another fab write its figures into `dfm`. A via under the fab's no-surcharge size is a low finding (extra cost), not a fault. A figure in `dfm` or `board` overrides the profile, so a board can be held tighter than the fab.

## Debugging and fixing

Always read the exact message, then match it here.

| Symptom | Cause | Fix |
|---|---|---|
| `{saved:false, conflict}` | `base_rev` is old | `kicad_list` for the current `rev`, redo the edit with it |
| `The autorouter is busy` (429) | a job is still running | wait about a minute, call again |
| `status:"running"` | normal for Freerouting | repeat the call with `job` and `base_rev` |
| Autoroute `unconnected > 0`, nothing saved | `require_complete` refused an incomplete run | retry; widen spacing or add a layer; loosen the clearance only if the fab allows |
| Autoroute `Session import failed` | old tracks in the way (older server) | current server clears tracks first; if it persists, `remove_track` for the nets and retry |
| HTTP 504 or timeout on a long call | a runner job ran past the request time | use the job form (`kicad_autoroute`), do not retry blindly |
| DRC `clearance` after changing rules | old copper is closer than the new rule | re-route, or move parts apart |
| DRC `hole_clearance` from a connector | the footprint's own holes are closer than the rule | set `min_hole_clearance_mm` to what the footprint needs and the fab allows via `set_rules` |
| DRC `courtyards_overlap`, `copper_edge_clearance` | parts too close or too near the edge | `move_footprint`; keep 0.3 mm from the edge |
| DRC `silk_over_copper`, `silk_overlap` (warnings) | reference text on pads | `set_silk_text_size` smaller, or move the text; these do not block fab |
| DRC `track_dangling` | stub left by a removed connection | `remove_track` for that net segment and re-route |
| ERC `pin_not_connected` / `pin_not_driven` on pins left open on purpose | no no-connect flag | `kicad_sch_labels` op `no_connect {ref, pins: "unused"}` (or a pin list) on the part's sheet; check first that a floating input really may float (datasheet) |
| ERC `power_pin_not_driven` on a rail fed from a connector or a part ERC does not count as a source | nothing marks the rail as driven | `kicad_sch_labels` op `power_flag {net}` on a sheet where the net has pins (refused if a power output already drives it) |
| ERC `label_dangling`, `wire_dangling`, `pin_to_pin` between two PWR_FLAGs | a leftover label, stub or second flag | `kicad_sch_labels` ops `remove_label {net, at}`, `remove_wire {at}`, `remove_power_flag {ref}` with the `x_mm`/`y_mm` (and `other`) that `kicad_erc` reports |
| ERC `... library 'X' not in configuration` | the store has no library tables | warning only; ignore |
| Zero parsed components from a netlist | multi-line netlist format | parse with a tolerant regex |
| `kicad_build` result says done but `saved:false` and `changed_files:[]` | the tool kept its change in memory only (that is why `erc_set_rule_severity` was removed) | treat the change as not made; do it with `kicad_edit`, `set_rules` or `kicad_put` |
| `sch_build_circuit` removed my symbols | it replaces the whole sheet with what you pass (symbols, labels); wires are not taken from it | send every symbol and label you want to keep, then add wires with `sch_add_wire`; use it on a new sheet only |
| `unknown tool for this profile` | the KiCad server does not have that tool | see `kicad_tools`; use `kicad_edit` ops or generate the file and `kicad_put` it |
| Autoroute `Session import failed` on a board with no parts | nothing to route: footprints are missing | `kicad_sync_pcb` first |
| `lib_assign_footprint` says `Footprint 'lib:name' was not found` for a project library | the project has no `fp-lib-table` pointing at `_libs/<lib>.pretty` | set the field instead: `kicad_build sch_update_properties {reference, field:"Footprint", value:"lib:name"}`; `kicad_sync_pcb` finds the footprint in `_libs/<lib>.pretty/<name>.kicad_mod` |
| `kicad_sync_pcb` lists `no_footprint_assigned` | the schematic part has no footprint | `kicad_build lib_assign_footprint {reference, library, footprint}`, then sync again |
| Fan-out via for a supply pad shorts or clears badly | the via landed on a neighbouring track | try other spots (further out, offset sideways) in a `kicad_edit` dry run until DRC shows no new errors; do not save a try that adds errors |
| `kicad_build` says `Field required` | arguments were not passed | put them under `arguments`, with the `_mm` names (`x_mm`, `y_mm`) |
| `sch_update_properties` validation error | needs `reference`, `field`, `value` | pass those, not a `properties` object |
| `kicad_drc` / `get_rules` / `list_nets` say `circuit must be a circuit name` or `Bad circuit name` | `circuit` missing or given with an extension | pass `circuit` as the bare name, e.g. `fido2-key` (not the file path, no `.kicad_pcb`) |
| `kicad_review` says `Unknown tool for kicad_review` | `tool` missing | pass `{project, path, tool}`, e.g. `tool:"run_drc"`; `kicad_tools` lists the names |
| `kicad_drc` lists `inside_footprints` (e.g. `drill_out_of_range` on a module's thermal vias, `hole_clearance` between a connector's pads and its pegs) | a stock footprint's own holes or pads are under this board's limits; moving or routing never clears them | decide at placement, not at the end: if the fab accepts the footprint, put the board rule at the fab's limit (`set_rules`); otherwise copy the footprint into the project library with the size corrected, name it in the symbol's Footprint field (`kicad_build lib_assign_footprint`) and `kicad_sync_pcb`. Never trim a maker's land pattern to satisfy a rule |
| library check fails with "board footprint is not the one the schematic names" after `update_footprint` | the footprint was swapped on the board only | set the symbol's Footprint field to the board's footprint; a `kicad_sync_pcb` before that puts the old one back |
| `check_zones` reports a fast net over a plane gap | USB, a differential pair or a clock crosses a cut in its ground | a routing fault: move the track or the cut in the routing step; pours cannot fix it |
| `kicad_review run_drc` counts one more than `kicad_drc` | the two use different report paths (the review text adds a summary count) | trust `kicad_drc` counts for gating; use the review text only for the violation details |
| `kicad_edit` op `add_keepout` takes `layers: [..]` | `layer` (singular) is rejected as an unknown key | `{op:"add_keepout", layers:["F.Cu"], polygon, no_copper, no_vias, no_tracks}` |
| `download_circuit_source` says the files come to more than 24 MB | `inline` or `save_asset` builds the zip in one request | pass `include` globs (e.g. `["*.pretty/*"]`) and `models: false`: the filter is applied before the limit; or leave `inline` out for a download link, which has no such limit. To read one stock footprint use `kicad_edit` op `read_footprint` instead |
| a repair run ended with no check closed | the check needs a decision, or the same approach was repeated | read `get_evaluation` `repair`; follow "Repair without waste" |
| `kicad_put` too large / upload "did not succeed" | file over the inline size | `kicad_import_zip` |
| Login loop on `/?project=...` | query on `/` never reaches the Worker | open `/projects?project=<id>&circuit=<name>` |
| 401 on `/mcp` | token expired or revoked | make a new token at `/settings/mcp` |
| 403 | role too low or token limited to other projects | ask an owner, or use a token with the project |

When something is wrong and the cause is not in the table: run `kicad_drc` and `kicad_review run_erc`, look at the first finding's position, fix that one thing, and re-run. Fix one cause at a time; do not stack edits.

## Verifying a change

After any edit report the new `rev`, then the DRC counts (`violations`, `unconnected`, by severity), not only "done". If a check could not run, say so. A board is finished when `get_evaluation` says `current: true` (its latest evaluation passed and nothing was saved since) and the BOM has no MISSING sourcing rows. Any save makes the evaluation outdated: run `run_evaluation` again before saying a board is verified or asking for fab files.

## House rules

- Every drill, via or pad, is at least 0.25 mm (0.25 mm allowed; smaller is not). KiCad DRC also flags smaller holes (`drill_out_of_range`) and the autorouter places no smaller via; fix existing vias with `kicad_edit set_via_size` and a stock footprint's plated holes (ESP32 module thermal pad, QFN ThermalVias at 0.2 mm) with `kicad_edit set_pad_drill {drill: 0.3, refs}` (DRC then lists `lib_footprint_mismatch` for those parts: expected). `check_dfm` fails a board that has smaller ones (`dfm:house-drill`), on every fab profile; `kicad_edit` refuses `add_via`, `via_array`, `stitch_vias` and a net class `via_drill` below 0.25 mm. Do not propose HDI micro vias or a rules.json limit to get around it.
- Agent settings can differ per project: `agent_settings {project}` lists them, `agent_settings {project, key, value}` sets one (owner; value null clears). A project can pick cheaper models and a lower cost limit, never more than the admin allows.
