MCP and live control
Getting started
Section titled “Getting started”Build the CLI, start MCP on stdio, and call design.summary and inspect_design before any edit.
For the same project the desktop shows, run the app with --control and connect
with pcbcraft-cli mcp --connect. Tool and command counts on fork main are in
getting-started.md.
cargo build -p pcbcraft-clicargo run -p pcbcraft-cli -- mcpDetails
Section titled “Details”The executable pcbcraft-cli mcp implements a stdio MCP server. It negotiates
2025-11-25, 2025-06-18 or 2024-11-05 protocol versions, advertises tools, and returns
tool failures as isError responses. Messages are capped at 1 MiB. Until a
successful initialize, the stdio server answers every request except initialize and
ping with error -32002; notifications get no reply.
Example client configuration after cargo build -p pcbcraft-cli:
{ "mcpServers": { "pcbcraft": { "command": "/absolute/path/to/target/debug/pcbcraft-cli", "args": ["mcp"] } }}For a visible session, launch:
pcbcraft --sample --control 127.0.0.1:7991pcbcraft-cli mcp --connect 127.0.0.1:7991The bridge binds only to literal loopback addresses. It is trusted local automation with filesystem access as the invoking user. It has no remote authentication. Only tools/call requests are forwarded; tool discovery comes from the same registry. Do not expose this port through forwarding to an untrusted network.
Assistant gated bridge
Section titled “Assistant gated bridge”When the desktop assistant starts a user’s coding agent, it also starts a separate
loopback MCP bridge (start_gated_bridge in crates/mcp). That bridge picks a free
port on 127.0.0.1, returns the port to the app, and requires a per-launch random
token on every JSON line. Requests without a matching token get error -32001
(unauthorized). tools/list is answered locally from the tool registry;
tools/call is handed to the assistant gate and may wait up to 300 seconds while
the user approves a change.
The agent’s MCP entry uses pcbcraft-cli mcp --connect 127.0.0.1:PORT --token TOKEN.
The token is passed on the command line in the agent session setup, not in the agent’s
environment. An agent could read its own session parameters; the gate, not the token,
is the real guard.
For manual testing, pass the same token to the CLI:
pcbcraft-cli mcp --connect 127.0.0.1:PORT --token TOKENWhen --token is omitted, PCBCRAFT_CONTROL_TOKEN is used (the same variable name
as for the unauthenticated --control bridge, but the assistant bridge uses a fresh
token each launch).
How the server measures against the specification, and the test list, are in mcp-conformance.md.
Recommended agent flow
Section titled “Recommended agent flow”design.summary: a short, bounded view of the design (counts, board, parts, nets, findings). Read it first.inspect_design: read current revision, stable IDs and capability limits when you need a full record.list_commands: inspect schemas and millimetre/degree units.executeorbatch: supplyexpected_revisionwhen coordinating concurrent edits.checks: inspect scope, findings and object IDs; initial checks are not full ERC/DRC.screenshot: obtain a PNG design preview ofschematicorpcb.save/export: use server-host paths. WSL paths differ from Windows paths.
Every engine command is also a directly callable MCP tool, such as component.add
or board.cutout.add. Use the generic execute wrapper for revision guards.
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"example","version":"1"}}}{"jsonrpc":"2.0","method":"notifications/initialized"}{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"execute","arguments":{"command":"component.add","params":{"kind":"resistor","position":{"x":30,"y":20}},"expected_revision":0}}}{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"inspect_design","arguments":{}}}Atomic batch example:
{"commands":[{"command":"board.resize","params":{"width":80,"height":50}},{"command":"board.cutout.add","params":{"center":{"x":5,"y":5},"radius":1.6}}],"expected_revision":1}The entire batch is one undo step. Failure leaves document, revision and history unchanged. New/open/sample replacements are undoable. IDs are not recycled after undo.
screenshot renders a headless design preview; it does not capture desktop chrome.
To capture the actual UI, use the desktop’s --capture /absolute/path.png option.
Library workflow
Section titled “Library workflow”library.list filters part listings (embedded Samtec connector series records, the open project’s saved parts, installed libraries and any listings you pass) with one
filter (categories, packages, value_min, value_max, voltage_min,
temp_range, stock_min, lifecycle, sources, rohs, text), limit
(1-100) and a cursor from the previous answer. It returns items,
next_cursor and total_known. A listing with an empty number never matches a
numeric filter. Results are grouped by source in each source’s own order and are
not ranked across sources. Optional listings carries already loaded
distributor pages to filter with the same rules. It is read-only.
library.catalog discovers host folders and returns configurable_connectors (the embedded Samtec series catalog; see docs/samtec-library.md). library.search accepts path, kind
(symbol or footprint), optional query, and limit (1–100). A symbol path is
a .kicad_sym file; a footprint search path is a .pretty directory. Results
report search and directory-scan truncation. library.inspect_symbol accepts
path and name; library.inspect_footprint accepts a .kicad_mod path.
Read tools return resolved geometry and unsupported features without changing or
locking the project. Symbol catalogs cache two files using length/mtime; restart
to refresh external replacements deliberately preserving both metadata fields.
component.place_library accepts path, symbol, position and optional
reference/value. footprint.assign accepts component id and footprint path.
The engine validates supported placement and exact numbered-pin/pad correspondence,
embeds the used definitions, and makes assignment undoable. board.sync returns
unassigned_components rather than inventing packages for imported symbols.
These commands also work in atomic batches and the live desktop bridge.
part.attach_source records distributor answers on a placed component in one undo
step. It requires component id, non-empty manufacturer and mpn, and accepts
optional datasheet, distributor, sku, stock, retrieved_at, and checked_at. It writes named properties
Manufacturer, MPN, Datasheet, and either SKU or <distributor> SKU when a
seller line is present. Length and control-character checks match component.field.
The library crate searches online part sources; the engine does not call them.
component.move and component.rotate accept optional unit (default 1) for
independent schematic unit placement. All package pins still use the same
component ID and physical pin number. track.route accepts layer (F.Cu default
or B.Cu) and requires copper on that layer at both endpoints. Plated through-hole
pads connect their own front/back copper; two different pads are never bridged.
track.route_pair takes four pad refs (from_p, from_n, to_p, to_n) for a
declared differential pair, optional width, and layer (default F.Cu). It
routes both nets with coupled orthogonal L geometry and refuses when the pair gap
cannot be kept.
track.tune_skew takes a differential pair id or name, optional layer
(default F.Cu), and a declared length_tolerance on the pair. It serpentines
the shorter net until skew is within tolerance, in one undo step.
track.drag takes a track id, which end (“start” or “end”), a position and an
optional mode (octilinear by default, or octilinear_shove). The other end stays
put and the track is re-laid as 45-degree copper around pads, cutouts and other
nets’ tracks; shove mode also pushes other nets’ tracks aside within fixed limits.
A refusal gives a plain reason and changes nothing. track.set_end stays the
unchecked move.
A run is one track record per straight piece. A corner is therefore two records
sharing a point. A drag on one end carries every other piece that meets it. A
corner stays a corner. The ids of the carried copper come back in carried. A
piece is carried when it shares the point on the same net and the same layer.
Pieces joined through a via sit on another layer and stay put, since the via
does not move. A carried piece whose far end is the new position has become
nothing and is dropped. That is what straightening a corner away means.
library.inspect_symbol and library.inspect_footprint accept include_source.
When true, up to 512 KiB of original nodes are returned for editing; larger source
nodes report source_truncated. The GUI disables copying truncated definitions.
Original files are never modified by placement or editing.
Native library authoring
Section titled “Native library authoring”library.symbol.upsert / library.footprint.upsert accept a full validated
definition DTO and optional attribution notice. Inspect a source definition
with include_source: true, or construct one using the fields documented in
docs/kicad-libraries.md. library.symbol.remove / library.footprint.remove accept
name. component.place_custom accepts name, position, optional reference/value;
footprint.assign_custom accepts component id and footprint name.
library.pin_pad_assign (name, pin, pad, optional only) chooses the footprint pad a
symbol pin drives on a project-library part, and library.pin_pad_role (name, pad, role of
electrical, mechanical, thermal or no_connect) says what a pad is for. Each is one undoable step,
refuses an unknown part, pin, pad or role without changing anything, and returns the pin to pad
findings after the change.
library.import_online adds a part fetched from an online library to the project
library in one undoable step. It takes a symbol definition, an optional footprint
definition, an optional model (a file path with optional offset, scale and rotate),
up to four notices that record the source and licence in the project library, and
on_conflict (refuse by default, replace, or keep_both). Importing identical
content again changes nothing and answers unchanged. library.place_online does the
same import and then places the part: target is schematic or layout, position
is the drop point in that view, and a layout drop also adds the part to the schematic
at a free spot, with the footprint on the board at position. Pad numbers must match
the symbol pins or the whole command changes nothing. The engine never fetches files;
the caller reads them with the library crate first.
library.save {path} atomically writes a .pcbcraft-lib collection without
changing history. library.load {path} validates and replaces the project-library
collection as one undoable edit. Collections carry format: "pcbcraft-library",
version: 1, and library containing symbols, footprints and notices. These
operations retain original nodes/notices and reject unknown native fields.
Placed components retain embedded copies when library definitions are edited or
removed; edits do not silently rewrite existing circuits.
pcbcraft-cli tool library.catalogpcbcraft-cli tool library.search --args '{"path":"/usr/share/kicad/symbols/Device.kicad_sym","kind":"symbol","query":"resistor","limit":20}'Fabrication and output jobs
Section titled “Fabrication and output jobs”gerber.export writes front and back copper, outline and Excellon drill into a
directory without editing the project. output_job.add records a named recipe
(listing export kinds such as gerbers, netlist, bom, placement, dxf,
panel, layer_plots, conformal_coat and raster). output_job.run writes every file in that
recipe into one folder after layout changes. Drawn silk, mask and machine layers
in layer_plots become their own Gerber, DXF, SVG and HP-GL files as positive
ink, not negative soldermask from pads. The conformal_coat kind writes one
Gerber keep-out plot from the drawn layer named in board.set_conformal_coat_keepout.
The raster kind writes six high-DPI
PNGs (top and bottom copper, mask and legend). panel.export duplicates
fabrication outputs for every copy when a panel grid is enabled.
Virtual probes
Section titled “Virtual probes”A probe is a virtual instrument: a point on a net or pin of the design whose DC voltage the
simulator reports. It touches no hardware. The schematic and the layout both place probes through
probe.add: a click on a schematic pin or a layout pad names the pin (the pad number is the pin
number of the same part), and a click on a wire, track or via names the net. probe.add takes exactly one of net or pin (a
component id and pin number), an optional reference net (ground by default) and an optional
label of up to 40 bytes, and returns the probe id. probe.remove takes an id. Each is one
undoable step, a design holds at most 64 probes, and a refusal (an unknown net, pin or id, both
or neither point, a repeated point, a probe measured against its own net) changes nothing.
probe.list returns the probes with their point in words. probe.read runs the same solve as
sim.dc and returns each probe’s volts relative to its reference. When the solve cannot run,
solved is false and reason is a plain sentence, and a probe on a net the solve does not reach
has volts null and a note; no number is made up. Both read commands leave the revision alone.
Probes are stored with the design, and a probe whose net or pin is deleted is dropped with it.
The readings are DC only and follow the limits of sim.dc: two-pin R, V and I parts with a
sim.model field, and a net named GND or 0 for ground.
A probe can also say what it should read, which turns it into a behaviour test. The expected range
is min and max in volts, both optional but at least one present, each a finite number from
-1000 to 1000 with min not above max. probe.add takes it as an optional expect object, and
probe.expect sets it later: give id with min, max or both, or with target and
tolerance_percent (0 to 100, a share of the target’s size; stored as min and max, so
target 5 with tolerance_percent 5 becomes 4.75 to 5.25), or give id with clear true to
remove it. Setting replaces the earlier range, each call is one undoable step, and a refusal (an
unknown id, no bounds, min above max, a value out of bounds, a target without a tolerance, a
range given both ways, clearing a probe that has none) changes nothing. probe.list returns each
probe’s expect. probe.read adds to each probe a status and a plain status_reason: pass
when the reading is inside the range (a reading on a bound passes), fail when it is outside, and
unchecked when the probe has no range or the solve could not run or did not reach its net, in
which case the reason says why and no number is made up. A probe that fails raises the finding
probe_out_of_range, a warning by default, naming the probe, the reading and the range; it is
listed with the other findings in the findings panel, on the Checks page and in checks, a
severity set with rules.severity applies to it, off hides it, and no finding is raised while
the solve cannot run. An assistant can set expectations from a datasheet or from the intent of a
rail (for example 3.3 V within 5 percent on the supply of a part), place the probes, and read back
pass or fail through these same commands, with nothing added for it. The check is DC only and
follows sim.dc.
Limits
Section titled “Limits”MCP messages are capped at 1 MiB. The live bridge is loopback-only trusted
automation with no remote authentication. Initial checks exposed through checks
are not full ERC/DRC. Preview export supports PNG and SVG for schematic/PCB
views; it does not write fabrication BMP rasters (those PNGs come from output
jobs).
Cancellation
Section titled “Cancellation”The MCP spec lets a client send notifications/cancelled with a requestId so the
server can stop work for that call. PCBCraft treats every JSON-RPC message without
an id as a notification: handle_rpc returns no reply, including for
notifications/cancelled. The server does not track in-flight request ids and does
not stop a tool that is already running.
On stdio, serve reads stdin one line at a time and only handles the next message
after the current tools/call finishes. A cancel notification sent while a long
export runs is not read until that call returns, so it cannot interrupt
output_job.package, step.write, odb.write, pdf.write, or similar file
writers. The loopback --connect bridge handles one request per TCP connection with
the same limitation. Stopping mid-export would need a concurrent reader and
cooperative checks inside the writers; that is out of scope for the current server.
Fast tools do not need cancellation in practice.
See also
Section titled “See also”- architecture.md for the mutation boundary and crate layers
- kicad-libraries.md for library DTO fields used in authoring
- README CLI and MCP for copy-paste sample commands
Tool hints
Section titled “Tool hints”Every tool in tools/list carries a title and an annotations block with the four
MCP hints, so a client can decide when to ask the user first.
| Kind | Tools | readOnly | destructive | idempotent |
|---|---|---|---|---|
| Read only | inspect_design, list_commands, checks, board_mesh, screenshot, library.catalog, library.search, library.list, library.inspect_*, library.compare, library.drop_in_check, library.sources, design.recents, design.list_open, design.activate |
yes | no | yes |
| Writes files outside the project | *.write, *.export, export, save, library.save, library.export_*, output_job.package |
no | no | yes |
| Replaces the whole design | new_design, sample_design, open |
no | yes | no |
Everything else (execute, batch, undo, redo, engine commands, library.add_folder, library.remove_folder) |
edits that can be undone | no | no | no |
openWorldHint is false for every tool. The title is the tool name with dots and
underscores turned into spaces. The table lives in annotations_for in
crates/mcp/src/lib.rs.
Streamable HTTP
Section titled “Streamable HTTP”pcbcraft-cli mcp --http 127.0.0.1:PORT serves MCP over the Streamable HTTP transport
(revision 2025-11-25) on one endpoint, http://127.0.0.1:PORT/mcp. It prints the endpoint
and a per-run random bearer token to stderr; stdout is never used. With
--token-file PATH the token goes to that file (mode 0600) and is not printed.
pcbcraft-cli mcp --http 127.0.0.1:7992 --token-file ~/.pcbcraft-mcp-tokencurl -s http://127.0.0.1:7992/mcp -H "Authorization: Bearer $(cat ~/.pcbcraft-mcp-token)" \ -H "Accept: application/json, text/event-stream" -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'The full guide, with sessions, progress streaming, cancellation and the remote opt-in, is in mcp-http.md. In short:
- It binds a literal loopback address by default; another address needs
--allow-remote. - Every request needs
Authorization: Bearer <token>(401 otherwise). A foreignOriginorHostgets 403; a request with noOriginis allowed. - POST carries requests (200 with JSON, or an event stream with progress when asked), a
notification gets 202,
DELETEends a session, GET gets 405. initializeissues anMCP-Session-Id.notifications/cancelledstops a queued call.- It reuses
handle_rpc, the same dispatcher as stdio and the--controlbridge.
Resources
Section titled “Resources”The server advertises resources (no subscribe, no list-changed notice) and answers
resources/list, resources/templates/list and resources/read. Reading never edits the
design; it goes through the active design like the tools do.
| URI | Type | Content |
|---|---|---|
pcbcraft://design |
JSON | Same as inspect_design |
pcbcraft://summary |
JSON | Same as design.summary |
pcbcraft://commands |
JSON | Same as list_commands |
pcbcraft://checks |
JSON | Runs checks when read; there is no stored last result |
pcbcraft://design/preview/{view} |
PNG blob | schematic or pcb, same renderer as screenshot |
An unknown URI is error -32002 “Resource not found” with the URI in data. A preview view
other than schematic or pcb is -32602.
Prompts
Section titled “Prompts”The server advertises prompts (no list-changed notice) and answers prompts/list and
prompts/get. Prompts are templates the user picks; each only names tools from tools/list.
| Prompt | Argument | What it asks the model to do |
|---|---|---|
review_board |
focus: placement, power or signal (optional) |
Call inspect_design and checks, review, report by object id, edit nothing |
fix_findings |
none | Call checks, fix the findings by object id with execute or batch, check again |
fix_unrouted_nets |
none | Call checks, route the unrouted nets with execute or batch, check again |
prepare_fabrication |
fab: short text (optional) |
Run checks, stop on errors, else write outputs with gerber.export, bom.write, placement.write |
An unknown prompt name or a focus outside the list is error -32602. Argument text is
inserted as plain text and clipped to 200 characters.
Browser model routes (research notes, November 2026)
Section titled “Browser model routes (research notes, November 2026)”WebMCP is a draft from the W3C Web Machine Learning Community Group, not a standard. It
lets a page register tools that an in-browser agent can call; it ships only behind a
Chrome origin trial, and sources disagree on whether the entry point is
navigator.modelContext or document.modelContext, so feature-detect both and check the
draft and the Chrome release notes before relying on either name. PCBCraft would expose
its existing tool list through it, using the same names as tools/list.
WebGPU is available by default in Chrome and Edge (since version 113), and in recent Safari
and Firefox with gaps (Firefox on Linux and Android). Libraries such as WebLLM run models on
it behind an OpenAI-style chat API, which fits the ModelProvider wire format already used
by CloudProvider. A local model should run in a Web Worker and report through the same
callback. Sources: the WebMCP draft and the web-features explorer entry for
modelContext; MDN’s WebGPU compatibility table; the WebLLM project documentation.