kicad-mcp
# boardproof
An MCP server for PCB design in which nothing counts as finished unless a machine-checked gate says so. The Python package is `boardproof` and the start command is `boardproof`.
An MCP server that lets an AI agent do PCB design work in KiCad: component sourcing, schematic construction, placement, routing (KiCadRoutingTools or Freerouting), verification, SPICE simulation and manufacturing export. It drives KiCad through its files and `kicad-cli`, so no running KiCad is needed.
Who it is for: people who want an MCP client (Claude Code, Claude Desktop or another) to carry out real KiCad 10 work and who care more about a result they can trust than about a result that looks finished. Everything is built around one rule: a board is "done" only when a machine-checked verdict says so. A short tour of the design is in [docs/OVERVIEW.md](docs/OVERVIEW.md).
## Status (2026-10-29)
**No board has passed the acceptance gate as a plain PASS yet.** The tools exist and are tested, but no tool chain has delivered a routed board end to end that the gate accepts without a qualifier. Rung 1 has boards with `PASS (necked)` (protocol 6, Freerouting 5 of 5); the rung-1 board changed afterwards (protocols 7 and 8) and has no official batch under the current protocol. The product promise is therefore tiered by board class:
- **Copilot tier (default):** you own power routing and zone topology in KiCad. The agent handles schematic, placement, signal routing and verification.
- **Autonomous tier:** offered only for board classes that have passed the gate on the acceptance ladder. **Currently none.**
Words used below: a **rung** is one reference board on the acceptance ladder (an ordered set of boards a pipeline must pass, easiest first); **KRT** is KiCadRoutingTools, a third-party router this project runs as a subprocess; the **owner** is the person who decides the scope and rules of this project; a **build ticket N** is an internal work item id and may not be resolvable in a public copy (the fact is always stated in words next to it); a **protocol** is the frozen, numbered plan by which a rung is measured. [docs/CONTEXT.md](docs/CONTEXT.md) has the full glossary.
What the measurements say (five attempts per backend and rung, official batches, 2026-10-28):
| Rung | Board | Protocol | Freerouting 2.5.0 | KiCadRoutingTools 0.23.1 |
|---|---|---|---|---|
| 1 | USB-C ATtiny1616 breakout, 2 layers | 6 | 5 of 5 attempts `PASS (necked)` | 0 of 5 |
| 2 | KiCad's `pic_programmer` demo, tracks removed | 5 (no protocol-6 batch has run) | 0 of 5; cannot pass | 0 of 5; cannot pass |
- **A `verify_board` PASS means the board is connected and DRC-clean. It does not mean the layout is good**: a decoupling capacitor 6 mm from its supply pin, a badly ordered power path or a noisy return all pass the gate. `check_decoupling_placement` (verification toolset) is one narrow, read-only placement check, not a layout verdict.
- **`PASS (necked)`** means the board passed the gate (zero unconnected items, zero error-level DRC violations, all zones filled), but it carries counted necks: tracks narrower than their net class right at a pad entry, which the protocol accepts as "forced" when the pad geometry limits the width (at the 0.2 mm gap between U1's pads, a 0.2 mm track is the widest that keeps the class clearance). The Freerouting boards carry 3 such necks on `+3V3` at U1 pad 4, 2.1476 mm in total. It is a weaker statement than a plain PASS, it is always labelled, and no rung is claimed from it.
- **The 5 of 5 depends on one open decision.** The first segment of each neck is 0.15 mm wide where the pad would allow 0.2 mm. Under the protocol's current reading that still counts as forced; under a stricter reading all five attempts would FAIL. The owner's decision on a neck below the pad limit is still open (build ticket 111, item 3).
- KiCadRoutingTools scored 0 of 5 on rung 1 under protocol 6 because version 0.23.1 read the board's 10 unquoted pad names of the USB-C footprint as zero pads. The board and the router checkout have since changed (the checkout is pinned to a newer commit) and no official batch has run on them yet (build ticket 112 holds the guard).
- Rung 2 cannot pass for any router: the demo's own silkscreen already carries 6 `silk_overlap` errors, which no router can fix (build ticket 106).
- Rung 3, the 20 A class openMPPT board, is frozen until rungs 1 and 2 pass.
Details and the exact meaning of each number: [docs/ROADMAP.md](docs/ROADMAP.md) and [docs/TESTING.md](docs/TESTING.md).
## Quickstart
1. Install (below) and add the server to your MCP client (below).
2. Ask the agent to open a project: `project_open` takes a project directory or a `.kicad_pro` file. `project_create` scaffolds a new one.
3. Load what you need: `list_toolsets` shows the toolsets, `load_toolset` loads one (`schematic`, `placement`, `routing`, ...).
4. Grade the board: `pin_rule_baseline` before you start work, then `verify_board` with the board path, `parity="required"` (or `"not_applicable"` with a reason) and the baseline. Only a `PASS` from `verify_board` may be called routed or done.
## Install
Requirements:
- Python 3.11 or newer.
- KiCad 10 with `kicad-cli` (required). Tested with 10.0.7.
- Tested on Windows only (Windows 11, KiCad 10.0.7): every measurement and every gate run was made there. The code does not knowingly depend on Windows, but nothing has been run on Linux or macOS. Where docs/TESTING.md names Ubuntu paths, they are KiCad's package layout, not something this project has run.
Clone with submodules, so the JLCPCB library comes along (about 103 MB; it is optional, see below):
```
git clone --recurse-submodules <repository-url>
cd <the cloned folder>
```
Already cloned without them? `git submodule update --init --depth 1` fetches them afterwards.
```
python -m venv .venv
.venv/Scripts/pip install -e ".[dev,krt]"
```
easyeda2kicad (AGPL-3.0) is a core dependency, installed with the package and used as a subprocess only, never imported. Extras: `dev` (pytest, ruff), `krt` (the runtime dependencies of KiCadRoutingTools: numpy, scipy, shapely, Pillow), `copilot` (kicad-python, for the live-IPC adapter).
### External tools
Each tool is found the same way: an environment variable first, then `PATH`, then the usual install locations. A missing tool makes the tools that need it return `status: incomplete` with install instructions, never a guess.
| Tool | Used for | Environment variable |
|---|---|---|
| KiCad 10 `kicad-cli` | **Required.** DRC, ERC, netlists, renders, exports, the gate | `KICAD_CLI_PATH` |
| KiCad's bundled Python | Freerouting's Specctra export and import; KiKit | `KICAD_PYTHON_PATH` |
| KiCadRoutingTools v0.23.8, commit `c64c0db2` (MIT) | Routing and placement optimisation, run from a checkout. `python scripts/setup_krt.py` restores it into `.tools/KiCadRoutingTools` (the default; the variable wins) and fetches its prebuilt router, verified by SHA-256 | `KICAD_ROUTING_TOOLS_PATH`, `KICAD_ROUTING_TOOLS_PYTHON` |
| Freerouting 2.5.0 jar (GPLv3) and Java 25 | Routing, as a subprocess | `FREEROUTING_JAR_PATH`, `JAVA_PATH` |
| ngspice 47 (pinned; `ngspice_con.exe` on Windows) | SPICE simulation. **Optional while the simulation map is parked** (owner decision of 2026-10-30, issue 40): the batch gate does not require it, and its live tests skip, counted, when it is absent | `NGSPICE_PATH` |
| KiKit | Panelisation | `KIKIT_PATH` |
| KiCad's demo projects | Inputs of the second rung and of the oracle tests | `KICAD_DEMOS_DIR` |
| KiCad's symbol libraries | Schematic building and tests | `KICAD_SYMBOL_DIR` |
All third-party tools, their licences and how they are used are listed in [THIRD_PARTY.md](THIRD_PARTY.md).
### Optional: the JLCPCB symbol and footprint library
Whether a part is a JLCPCB Basic, Preferred or Extended part is answered from a small index that ships with the repository, with no download. The ready-made symbols, footprints and 3D models behind that index (CDFER/JLCPCB-Kicad-Library, MIT, about 103 MB) are a git submodule that a plain `git clone` does not fetch. Fetch it when you want them:
```
git submodule update --init --depth 1 third_party/JLCPCB-Kicad-Library
```
Without it, asset lookups fall back to `easyeda2kicad` (a core dependency) and say so. The server looks for the library in this order: the `BOARDPROOF_JLCPCB_LIBRARY` environment variable, the submodule above, KiCad's third-party directory (a Plugin and Content Manager install). `jlcpcb_library_status` reports what it found and, for an empty or missing submodule, the command above. A new git worktree starts with the submodule empty; set `BOARDPROOF_JLCPCB_LIBRARY` to another checkout's `third_party/JLCPCB-Kicad-Library` to share it. To rebuild the index after moving the pin: `python scripts/refresh_jlcpcb_index.py`.
Optional parts index for `list_part_filters` and `filter_parts` (parametric part search): download the jlcparts cache yourself (`cache.sqlite3`, published as `cache.zip` in split parts by the jlcparts project) and set `BOARDPROOF_PARTS_INDEX` to the extracted file, or pass `index_path`. It is only read, never written; nothing is shipped or downloaded by this server, and every answer states the index date and flags an index older than 7 days.
#### Refreshing the library to upstream's newest commit
The pin stays on one commit so the shipped index is reproducible. To move it, run in a checkout whose submodule is initialised (the command above), from a clean tree:
```
python scripts/refresh_jlcpcb_index.py --update --dry-run # plan only: fetches into a scratch repository, changes nothing here
python scripts/refresh_jlcpcb_index.py --update # moves the pin, rewrites the index, stages both
```
It prints upstream's commit, the part counts and every part that changes tier (Basic, Preferred, Extended), then stages the new submodule commit and the index; you review and commit. It refuses, and moves nothing, when a symbol library that holds parts today holds none upstream (`library_emptied`), when the part count falls below 80% of the old one (`index_would_shrink`) or when a symbol file fails to parse. There is no override flag: to follow a real loss, move the pin by hand. The apply is all-or-nothing: if the index replace, the submodule checkout or `git add` fails, the old submodule commit, the old index bytes and the old staging are put back (or the exact commands to do so are printed). `--ref` must be a plain ref name and `--upstream` an https URL (a local directory only when typed on the command line); every fetch runs with `--` and with all git transports except https (and a typed local path) switched off. Upstream's newest commit was still broken when this was written (18 of 20 symbol files hold only a header), so the command refuses it today. Without the submodule the dry run works and the real run says what to fetch first.
#### Cross-checking the tiers against the daily parts CSV
While the library's own generator is broken (issue 41), the Basic and Preferred tiers in the index can age. `python scripts/check_jlcpcb_tiers.py --csv FILE` (or `--fetch` for the upstream `jlcpcb-components-basic-preferred.csv` of CDFER/jlcpcb-parts-database, https only, allow-listed host, 64 MB cap, a 60 s per-socket-operation timeout rather than a total deadline, kept in memory) reports tier changes, index parts absent from the CSV and CSV parts missing from the index, as counts plus capped lists (`--sample N`). It is read-only: it never rewrites the index or saves the CSV, prints no stock or price, exits 0 on a report and 2 on unreadable or malformed input. It compares tiers and LCSC numbers only, not footprints, symbols or manufacturers. The default URL was not fetched live, and the `library_type` values base/expand/extended are assumptions never seen live. Vendoring CSV content stays blocked until the terms of its data sources have been read.
## MCP client configuration
```json
{
"mcpServers": {
"boardproof": {
"command": "path/to/.venv/Scripts/python",
"args": ["-m", "boardproof.server"]
}
}
}
```
The installed script does the same: `"command": "path/to/.venv/Scripts/boardproof"` with no arguments.
Renamed from kicad-mcp (package `kicad_mcp`, environment prefix `KICAD_MCP_`) in build ticket 74: the package, the start command and the MCP server name are `boardproof`, and the environment variables `KICAD_MCP_*` are now `BOARDPROOF_*` with no fallback. After pulling the rename run `pip install -e .` again in the virtual environment and change the MCP client configuration (`-m kicad_mcp.server` becomes `-m boardproof.server`). Schematic backups made before the rename stay in the old backup directory (`%LOCALAPPDATA%\kicad-mcp\schematic-backups`) and are not read by the new name.
The server starts with 21 tools: the three toolset tools (`list_toolsets`, `load_toolset`, `unload_toolset`), `project_create`, `project_open`, the gate (`verify_board`, `pin_rule_baseline`) and the checkpointed pairs for input preparation, pour step, schematic import, board rules, board outline, keepouts and slots, and silkscreen minimums. Ten more toolsets load on demand with `load_toolset`: `verification` (12 tools), `sourcing` (17), `diagnostics` (3), `library` (5), `schematic` (47), `placement` (14), `manufacturing` (2), `routing` (6), `copilot` (9) and `simulation` (2). That is 117 more tools, 138 in total (counted from a running server on 2026-11-18; tests/test_docs_tool_counts.py keeps these numbers equal to the live registry).
## Usage log (local, anonymous, off with one variable)
The server keeps a small log of which of its own tools get called, so that unused tools can be found and slow ones fixed. It is **on by default and stays on your machine**: nothing is sent anywhere, and the logging code imports no networking module (a test checks it).
- **What is recorded**, one JSON line per tool call: the UTC start time, the tool's name, its toolset, the duration in milliseconds, the outcome (one of a fixed set of words: `ok`, `error`, `cancelled`, or the result's own status word such as `PASS`, `FAIL` or `INCOMPLETE` if it is on the reviewed list in `usage_log.RESULT_WORDS`; any other word is recorded as `other`, never copied) and a random id that is new for each server process.
- **What is never recorded:** arguments, results, file paths, part numbers, net names, user or machine names, environment values.
- **Where:** `usage.jsonl` in the `boardproof` folder of `%LOCALAPPDATA%` on Windows, `~/Library/Application Support/boardproof/usage.jsonl` on macOS, `$XDG_DATA_HOME/boardproof/usage.jsonl` (else `~/.local/share/boardproof/usage.jsonl`) elsewhere. The file is capped at 1 MB and rotates once to `usage.jsonl.1`. Set `BOARDPROOF_USAGE_LOG` to a file path to write there instead.
- **Turn it off:** set `BOARDPROOF_USAGE_LOG=off` in the server's environment (for example in the `env` block of the MCP client configuration). **Delete it:** delete `usage.jsonl` and `usage.jsonl.1`.
- **Read it:** `python scripts/usage_report.py` prints, per tool, the count, share, median and 95th-percentile duration, error rate and last use, then the tools that were never called (`--since DAYS`, `--json`, `--log FILE`).
## Principles
- **Evidence-gated:** a check that did not fully run says so and never reports clean.
- **`kicad-cli` is the judge:** structured DRC and ERC output, read in full. Renders are for humans only.
- **Batch tools:** operations take collections, not one item per call.
- **Checkpoints:** autorouting, autoplacement, ambiguous part matches and destructive edits return a proposal and a revision token. Nothing is written until you confirm, and for the newer checkpoint pairs a confirm is refused if the project's files changed in between.
- **Never hand-edit KiCad files:** every mutation goes through this project's tools, or through the project's write layer (`boardproof.write_layer`), which saves through a temporary file, a parse check and `os.replace`.
## Limitations
- **Sourcing:** Nexar and Digi-Key providers are not built (they need credentials). The LCSC provider is blocked by a bot wall and returns an error rather than an empty list. The JLCPCB Basic parts index is vendored.
- **Autoplacement** (`propose_autoplacement`) is a naive row-packer. KiCadRoutingTools' placement optimiser is the stronger option.
- **Zones:** there is a pour step (`propose_pour_step` and `confirm_pour_step`) that adds a gate-graded plane zone from KiCadRoutingTools' plane script. There is no general zone-editing tool and no track or via removal tool.
- **Schematic editing tools** are unsafe on hierarchical (multi-sheet) projects; see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md), "Known facts and gotchas".
- **Windows only** so far.
## Tests
Several thousand tests (the current count is the last line of `python -m pytest --collect-only -q -m "not network"`). From the repository root:
```
python -m pytest -m "not network"
```
Tests that need an external tool skip with a stated reason when the tool is absent. The full gate, `python scripts/batch_gate.py`, runs the whole suite and the linter in a clean tree and ends with one `GREEN` or `RED` line; it takes about 45 minutes. There is no hosted CI: that local gate is the test gate. See [docs/TESTING.md](docs/TESTING.md).
## Documentation
| File | Contents |
|---|---|
| [docs/OVERVIEW.md](docs/OVERVIEW.md) | A ten-minute tour: how a tool call works, the gate, the ladder |
| [docs/CONTEXT.md](docs/CONTEXT.md) | Glossary |
| [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) | The decision record and the known facts and gotchas, with evidence |
| [docs/ROADMAP.md](docs/ROADMAP.md) | The acceptance ladder, carried-over defects, non-goals |
| [docs/TESTING.md](docs/TESTING.md) | The acceptance gate and the test suite |
| [CONTRIBUTING.md](CONTRIBUTING.md) | How to contribute |
| [THIRD_PARTY.md](THIRD_PARTY.md) | Third-party tools and data, with licences |
| [CLAUDE.md](CLAUDE.md) | Rules for AI agents working in this repository |
## Contributing and licence
Contributions are welcome; read [CONTRIBUTING.md](CONTRIBUTING.md) first. The code is MIT-licensed ([LICENSE](LICENSE)). Copyleft tools (Freerouting, easyeda2kicad) are only ever run as subprocesses. `kiutils` (GPLv3) is not used.
TDQS
Scored across 19 tools
The propose_/confirm_ pairing gives each operation a clear dry-run vs apply boundary, and verify_board is repeatedly (and correctly) framed as the single verdict tool, which resolves most confusion. A few pairs still sit close together: propose_input_preparation (moving copper text to silkscreen) vs propose_silkscreen_minimums (resizing text) both operate on the same board text, and the baseline pinning happens implicitly inside confirm_board_rules / confirm_input_preparation as well as in pin_rule_baseline.
The dominant pattern is verb_noun (verify_board, pin_rule_baseline, load_toolset), and the six propose_/confirm_ pairs are perfectly parallel. Deviations are minor but real: project_create/project_open reverse to noun_verb, list_toolsets uses a plural where load_toolset/unload_toolset use singular, and only the pour pair carries a '_step' suffix.
19 tools is on the heavy side, but half of them are the six propose/confirm pairs, which exist so that irreversible board writes require a dry run first — that doubling is justified by the domain rather than redundant. The five orchestration tools (list/load/unload_toolset, pin_rule_baseline, verify_board) and two project tools each carry a distinct role.
The visible surface covers a coherent forward pipeline (scaffold, outline, rules, schematic import, input prep, silkscreen, pour, verify) with no way to undo or remove anything once written. The documented stage order explicitly names 'routing' after the pour step, yet no routing tool appears here — it must come from a dynamically loaded toolset — and there is no export/manufacturing output (gerbers, drill, BOM) or board-inspection tool beyond project_open's summary.