This release is a pre-release and may not be stable for production use.
kicad-placement-mcp
Component placement for KiCad boards, as an MCP server for Claude (or any MCP client) and as a command-line tool.
You and the assistant decide the structure of the board: zones, anchors (connectors, ICs, anything you place by hand) and the design intent that the netlist does not show. The tool does the tedious, error-prone part deterministically:
measurea placement: overlaps, copper too close to the edge, pads on vias or tracks of other nets, parts in keepout areas, decoupling capacitors whose own pad blocks the route to their pin, IC power pins without a decoupling capacitor, isolation barriers, your constraints, and wire length (HPWL);placethe 2-pad passives (R, C, L, D, LED, ferrite beads, fuses) around the anchors, or, in conservative mode, fix only what is wrong in a placement done by hand;orientthe passives (90° steps) so that their pads face their nets and do not block the routes;applythe proposal to the board open in KiCad, through the official IPC API, in one undoable commit.
It never edits a .kicad_pcb file: it reads it with its own parser and writes only through KiCad.
BY1515_NUCLEO as it was routed (measure) |
The same board after place |
|---|---|
BY1515_NUCLEO is one of the two public test boards in tests/data. Left: the board as it was routed.
Right: what place proposes when its 47 two-pad passives are placed again around the same anchors, with the board's
rules file. Both images are the PNGs the tool writes,
unedited. Red pads are power, grey ground, yellow signal; thin lines are the signal ratsnest; the magenta ring marks
C8, whose own pad blocks the route to the pin it decouples (U3:16). From the tool's summary: blocked decoupling 1 → 0,
missed near rules 2 → 0 (C19 next to D3, R11 next to Q4), signal tree 476 → 489 mm (3 % longer). The board is
routed, so place warns that the proposal would leave tracks unconnected and apply would refuse it: this only
compares placements. Made with 0.1.0a1:
cd tests/data/BY1515_NUCLEO
kicad-placement measure BY1515_NUCLEO.kicad_pcb --rules placement/BY1515_NUCLEO.rules.json --png by1515-as-routed.png
kicad-placement place BY1515_NUCLEO.kicad_pcb --rules placement/BY1515_NUCLEO.rules.json --png by1515-place.png
Status: alpha (0.1.0a2). It has been used on about ten real boards, two of them public (in tests/data). Expect wrong placements: please report them. Read the limitations before trusting a proposal, and always review the result and run DRC before routing.
Install
Python 3.12 or newer.
pip install --pre kicad-placement-mcp
This installs both the MCP server (kicad-placement-mcp) and the command-line tool (kicad-placement). With
uv you can skip the install and register uvx kicad-placement-mcp instead.
Register the MCP server
Claude Code:
claude mcp add -s user kicad-placement -- kicad-placement-mcp
Claude Desktop or other clients (claude_desktop_config.json or equivalent):
{
"mcpServers": {
"kicad-placement": { "command": "kicad-placement-mcp" }
}
}
If kicad-placement-mcp is not on the client's PATH, give the full path of the script, or run the module with the
Python of your environment: "command": "C:\\path\\to\\.venv\\Scripts\\python.exe", "args": ["-m", "kicad_placement.mcp_server"].
apply changes the board open in KiCad. It is marked as destructive, so clients ask before running it; in Claude Code
you can make sure with "permissions": {"ask": ["mcp__kicad-placement__apply"]} in ~/.claude/settings.json.
Docker (MCP Toolkit)
The server is also published as an image. Mount the folder with your boards; the tools see it as /boards:
docker run -i --rm -v /path/to/boards:/boards ghcr.io/cvaldess/kicad-placement-mcp:latest
In Docker Desktop's MCP Toolkit you can add it to a catalog of your own with
docker mcp catalog create <your-catalog> --server docker://ghcr.io/cvaldess/kicad-placement-mcp:latest. It is also
listed in the MCP Registry as io.github.cvaldess/kicad-placement-mcp.
From a container, apply cannot reach KiCad's IPC socket on Windows or macOS: use the container for measure, place
and orient, and a local install (above) to apply.
Enable the KiCad IPC API (only for apply)
KiCad 9 or newer. In KiCad: Preferences → Plugins → Enable KiCad API, then open the board in the PCB editor
(the project manager alone does not serve it). apply connects to the default socket; pass --socket (CLI) if yours
is different.
How to use it
Ask the assistant in plain words, for example "measure my board", "place the passives around U3 and U5", "fix what is wrong in my placement without moving the rest" (conservative), "apply it". The tools:
| Tool | What it does | Touches the board? |
|---|---|---|
measure |
metrics and problems of the current placement | no |
place |
proposes positions for the movable passives (movable, or all 2-pad passives that are not anchors); conservative keeps what already complies |
no |
orient |
proposes rotations only | no |
apply |
takes the last proposal to the board open in KiCad, in one commit (one Ctrl+Z); does not save | yes |
Every call writes its result next to the board, in placement/: <board>.measure.json, <board>.place.json,
<board>.orient.json and a .png view of each (overwritten each time). The JSON of place says, for each part, where
it was, where it goes, how far it moves and why ("decoupling of U3:16", "next to the control pin Q2:1",
"stays: already complies where it is"…), plus a before/after summary.
Before applying, apply checks that the open board matches the file that was measured, part by part; afterwards it
reads the pads back and checks that every footprint is unchanged except for its position. If anything differs it
says so and reports ok: false. Parts with tracks connected are refused unless you force it (the routing would be
left behind).
Command line
The same actions, without an assistant:
kicad-placement measure board.kicad_pcb --png view.png --json measure.json [--rules rules.json]
kicad-placement place board.kicad_pcb --json place.json [--movable C1,C2,R5] [--conservative] [--rules rules.json]
kicad-placement orient board.kicad_pcb --json orient.json [--only C8,C10]
kicad-placement apply board.kicad_pcb place.json # to the board open in KiCad
On Windows, run Python with -X utf8 if the console shows mangled characters.
Rules
The design intent goes in placement/<board>.rules.json, next to the board (or --rules). Everything is optional.
Distances are in mm, edge to edge (courtyard ∪ pads); in constraints and exemptions, references accept * and ?
wildcards; "U2:31" means pad 31 of U2.
{
"anchors": ["C1", "R5"],
"movable": ["TP3"],
"decoupling": {"C8": "U3:16"},
"decoupling_exempt": ["U10:5"],
"overlap_exempt": ["J7", "J2–J3"],
"edge_exempt": ["J1"],
"edge_mm": 0.5,
"constraints": [
{"type": "near", "a": "C19", "b": "D3", "max": 1.5, "source": "input protection next to the connector"},
{"type": "separate", "a": ["J7:1", "J7:2"], "b": ["*"], "min": 2.0},
{"type": "outside", "footprint": "J7", "margin": 0.5, "except": ["J1"]},
{"type": "outside", "rect": [10, 20, 40, 35], "refs": ["C*", "R*"]},
{"type": "zone", "refs": ["R1?"], "rect": [50, 10, 70, 30]},
{"type": "edge", "ref": "J1", "edge": "left", "max": 1.0},
{"type": "side", "ref": "U4", "side": "F"},
{"type": "barrier", "dru": "barrera_tc", "min": 3.6, "nets": ["/GND_TC", "/+3V3_TC"], "footprints": ["U2"]}
]
}
| Key | Meaning |
|---|---|
anchors |
2-pad passives that must not move (exact references). Parts locked in KiCad and everything that is not a 2-pad passive are anchors already |
movable |
extra parts that may move (exact references: test points, net ties…) |
decoupling |
ties a capacitor to a pin; overrides the automatic assignment (also valid on signal nets: RC filters) |
decoupling_exempt |
power pins that do not need a capacitor next to them (the datasheet says so: e.g. an eFuse output) |
overlap_exempt |
parts, or pairs "A–B" / ["A", "B"], whose overlaps are intended |
edge_exempt, edge_mm |
parts allowed past the edge clearance, and the clearance (0.5 mm) |
near |
a within max of b |
separate |
copper of a at least min from copper of b |
outside |
nothing (or refs, minus except) inside a rectangle [x0, y0, x1, y1] or a footprint's courtyard, plus margin |
zone |
refs inside the rectangle |
edge |
ref within max of the board edge top/bottom/left/right |
side |
ref on side F or B |
barrier |
isolation between two domains: the nets, footprints and net classes of one side keep min from the rest; dru names the .kicad_dru rule it comes from |
source (or _note) is free text for you. If the .kicad_dru has an isolation clearance that no barrier covers,
measure warns and place refuses (unless forced): the proposal would not respect it.
Keepout areas drawn in KiCad, vias, tracks and copper zones are read from the board; they need no rules.
Limitations
- One side: only parts on their current side are placed; parts are not flipped.
- Anchors are not placed: connectors, ICs, crystals and anything not a 2-pad passive stay where you put them.
- Test points need a rule to move.
- Rotations in 90° steps only.
- Notes that depend on routing (keep away from a trace, Kelvin connections, differential pairs) are not modelled.
- Decoupling capacitors are assigned by geometry and pin types; bulk capacitors also by the schematic. Ambiguous cases
are reported and need a
decouplingrule. - No RF awareness.
- A full placement of a 150-part board takes a few minutes.
See DESIGN.md for how it works and why.
How it's built
I develop this tool with Claude Code, Anthropic's AI coding assistant. That is why the repository has a
CLAUDE.md: it is the file Claude Code reads at the start of every session, with the project rules (no
import pcbnew, never write a .kicad_pcb, never relax a tolerance to make a test pass). I review every change before
it goes in.
The placement criteria come from using the tool on my own boards. Each time it got something wrong (a part where I
would not put it, a check that missed a problem, an apply that lost the 3D models), the case became a numbered field
failure, F1 to F27 in DESIGN.md, and the fix came with a test: on one of the public boards,
on the private board where it appeared, or on a small board built inside the test that reproduces it.
- 66 tests in tests/, run by CI on Linux and Windows with Python 3.12, 3.13 and 3.14.
- 21 more on private boards, which I run on my machine and cannot publish.
applyis tested against a real KiCad: tests/test_apply.py starts KiCad 10.99 (the KiCad 11 nightly) without a GUI in Docker, applies moves and rotations through the IPC API, saves the board and reads it back pad by pad. CI skips these tests because it does not build the image; I run them locally.
English is not my first language. The tool and its documentation were first written in Spanish; the English version was written with Claude and reviewed by me. If a sentence is unclear, please say so in an issue.
Reporting a failure
Any placement you consider wrong is a failure of the tool or of the rules, and the most useful contribution you can make. Please open an issue with the Placement failure form and include:
- what you asked (tool and options, or the assistant's call) and the version (
pip show kicad-placement-mcp); - the part(s) and what is wrong, and where you would put them and why (a datasheet note, a layout rule of thumb);
- the
placement/<board>.<action>.jsonand.png, and yourrules.json; - the board files if you can share them (
.kicad_pcb,.kicad_pro,.kicad_dru,.kicad_sch). A failure that comes with its board becomes a regression test; if the board is private, a minimal board that shows the same failure works just as well.
Crashes and wrong measurements go in a Bug report. If you use the assistant, ask it to draft the issue: it has the JSON at hand.
Development
git clone https://github.com/cvaldess/kicad-placement-mcp
cd kicad-placement-mcp
python -m venv .venv
.venv/bin/pip install -e ".[test]" # Windows: .venv\Scripts\pip
.venv/bin/python -m pytest -q
The tests do not need KiCad, except tests/test_apply.py, which runs KiCad 11 nightly in Docker and is skipped if the
image is missing:
docker build -t kicad-placement-kicad:nightly-YYYYMMDD -f docker/kicad-nightly.Dockerfile docker
docker build -t kicad-placement-test:nightly-YYYYMMDD -f docker/test.Dockerfile docker
(Set IMAGE in tests/test_apply.py to your tag.) Read CONTRIBUTING.md before a pull request:
every change of criterion comes with a test on a real board.
License
GPL-3.0-or-later, like KiCad. The test boards in tests/data are CERN-OHL-S-2.0 (NOTICE).
This project is not affiliated with or endorsed by the KiCad project.
Metadata
Release files for kicad-placement-mcp 0.1.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kicad_placement_mcp-0.1.0a2.tar.gz | 118.6 kB | With provenance | Details for kicad_placement_mcp-0.1.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kicad_placement_mcp-0.1.0a2-py3-none-any.whl | Python 3 | none | any | Details for kicad_placement_mcp-0.1.0a2-py3-none-any.whl |
Total release size: 217.4 kB
Release files / kicad_placement_mcp-0.1.0a2.tar.gz
| Download URL | kicad_placement_mcp-0.1.0a2.tar.gz |
|---|---|
| Size | 118.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f5c19203f78c9c3f529f768fa399d3b600ceb6ee62924b08b0556495e5bb0af0
|
|
BLAKE2b-256 checksum How to use checksums |
98bfebbd9f9559bdbce4bfb205847099dd6896a93e91e4fccb570dc5174de1f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logRelease files / kicad_placement_mcp-0.1.0a2-py3-none-any.whl
| Download URL | kicad_placement_mcp-0.1.0a2-py3-none-any.whl |
|---|---|
| Size | 98.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d80d1616ad01fdc63036025c2d655f491855b36871036bb2045c254598ac631
|
|
BLAKE2b-256 checksum How to use checksums |
abefc91ec36c4526c0e0c579d2fd12ebef539488fca0d11b3a4fe0c4b86588f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logSecurity for kicad-placement-mcp 0.1.0a2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for kicad_placement_mcp-0.1.0a2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.