codex-kicad-mcp

v0.2.1
codex-kicad-mcp Checked 1 day ago Published 2 months ago

A safe, read-first MCP server for KiCad workflows in Codex.

A model reads the datasheet and fills a PartSpec, a JSON file in which every value carries the datasheet page and a verbatim quote. Deterministic code generates the KiCad files and checks them independently: against the spec, against the PDF, and by loading them in kicad-cli. The accuracy of model extraction has been measured on twenty-three parts in four small rounds, against answer keys written and checked by models and not yet reviewed by a human. See evals/README.md before relying on it. To try the development version instead: pip install "git+https://github.com/w23x0/kicad-partspec".

Summary extracted from the README.

kicad-partspec

Pre-alpha. Datasheet-derived PartSpec in, verified KiCad symbols and footprints out.

A model reads the datasheet and fills a PartSpec, a JSON file in which every value carries the datasheet page and a verbatim quote. Deterministic code generates the KiCad files and checks them independently: against the spec, against the PDF, and by loading them in kicad-cli.

The accuracy of model extraction has been measured on twenty-three parts in four small rounds, against answer keys written and checked by models and not yet reviewed by a human. See evals/README.md before relying on it.

Status

Piece State
PartSpec model, loader, spec-layer checks done
Source check (quotes must appear on the cited datasheet page) done
KiCad symbol generation (multi-unit, alternates, grid-aligned) done
Symbol checks (pins vs spec, grid, overlap, name collisions) done
kicad-cli load check done
Footprint generation (dual-row and quad packages, exposed pad) from the datasheet land pattern done
Footprint checks (pads vs datasheet, pads reach leads, silkscreen, courtyard) + kicad-cli load done
MCP server (3 tools), skill, plugin manifests done; loads with claude --plugin-dir (marketplace install not tested)
Extraction evaluation (evals/score.py, rounds 1 to 5 in evals/runs/) done, 23 parts, 2 runs each

Install

Python 3.10 to 3.13.

pip install kicad-partspec            # CLI
pip install "kicad-partspec[mcp]"     # CLI + MCP server

To try the development version instead: pip install "git+https://github.com/w23x0/kicad-partspec".

Optional tools the checks use when present: KiCad 9 or later (kicad-cli, for the load checks; without it you get a warning instead) and poppler (pdftotext, for the datasheet quote check).

The package contains the CLI and the MCP server. The skill that teaches a model how to extract a PartSpec, and the plugin manifests, live in the repository (skills/, .claude-plugin/, .mcp.json), not in the wheel.

Use

kicad-partspec validate SPEC.json [--datasheet FILE.pdf]
kicad-partspec build SPEC.json --out DIR      # writes <mpn>.kicad_sym and <lib>.pretty/<name>.kicad_mod, verifies both
kicad-partspec verify SPEC.json --symbol FILE --footprint FILE
kicad-partspec-mcp                            # MCP server; PARTSPEC_WORKSPACE limits the paths it may touch
python evals/check_gold.py --datasheets DIR_WITH_PDFS
python evals/score.py --extracted DIR --datasheets DIR_WITH_PDFS   # score model extractions against gold

Add --concise to print failures in full and warnings only counted by kind.

Gold cases and their conventions are in evals/README.md. Generated symbols target the KiCad 9 file format (version 20241209) and were loaded with KiCad 9.0.9.

Footprints are generated from the datasheet's example land pattern (land_* dimensions), not computed from a standard, so a part whose datasheet has no land pattern gets a symbol and a footprint.skipped warning that names the missing dimensions. Dual-row packages (SOIC, SOP, SSOP, TSSOP, MSOP, VSSOP, SOT-23 and TSOT-23) need an even pin count, and quad packages (QFN, VQFN, WQFN, UQFN, QFP, TQFP, LQFP) a pin count divisible by 4; an odd-pin SOT-23 such as SOT-23-5 has unequal rows and is skipped with that reason.

Repository workflow

AGENTS.md is the constitution every new agent session reads: the work loop, the red lines, and the gold-file arbitration protocol. The only progress signal is the audit board:

./scripts/audit.sh [--datasheets DIR_WITH_PDFS]

It prints the rule counts (total, covered, passing, failing, regressed, uncovered) from spec/rules.json plus three gold suites (gold-spec, gold-quotes, gold-build), and exits non-zero when a rule fails, a rule regresses, or a suite is not green. The datasheet PDFs are not stored here; without them the quote layer reports skipped and does not decide the exit status. An unattended loop drives one work cycle per round against that board (scripts/loop.sh); the round and independent-audit prompts are in scripts/prompts/.

History

This repository replaces codex-kicad-mcp, a read-first MCP server for KiCad projects. Its code is kept in the history and on the legacy branch; the tags v0.2.0 and v0.2.1 point at it.

License

MIT.