Schematic: apply ops
sch_applyApply a single atomic batch of schematic edits—place parts, connect pins by net name, and validate with ERC/netlist—so either all changes succeed or nothing is written.
Instructions
Edit the schematic with ONE atomic batch of ops (all succeed or nothing is written). Put a whole sub-circuit, or the
whole design, in a single call. Creates the .kicad_sch if missing. One call edits one sheet.
Pins are 'REF.PIN', PIN = number or name ('U1.PA9', 'J1.VBUS', 'R1.2'); a name on several pins connects them all.
Never compute coordinates: connect by NET NAME and Copper anchors the label or power symbol on the pin. New parts
take a temporary 'id' (one word) used in pins ('led.A'); the result's refs maps id to reference. Parts without
'at' are laid out automatically, and a sheet only Copper has arranged is re-drawn as titled functional blocks
(layout='keep' never does that; nothing is redrawn unless the netlist is proven identical).
ops (objects with "op"):
place: lib_id | lcsc "C25804" | part (+provider) | spec "10k 0402" (resolved by the parts providers); id, ref, value, footprint, fields {LCSC:..}, near (ref/id), group mcu|power|connector|passive, at [x,y], rot, mirror, unit, dnp
connect: pin | pins [..], net (power names like GND, +3V3, VBUS become power symbols; kind:'global' between sheets)
power: pin(s), net · no_connect: pin | pins · pwr_flag: net · wire: from, to | points · label: net + pin | at
set_field: ref, field, value | fields · move: ref, at | by, rot, mirror · swap: ref + lib_id | lcsc | part | footprint
delete: ref | label | wire_at [x,y] | dangling:true · disconnect: pin(s) · rename_net: from, to · text: text, at The result has what changed, the netlist check of every requested connection and KiCad's ERC with a ready
fixper issue, so a separate verify call is not needed. Example: ops=[{"op":"place","lib_id":"Regulator_Linear:AMS1117-3.3","id":"ldo"},{"op":"place","spec":"10uF 0805","id":"cin"}, {"op":"connect","pins":["ldo.VI","cin.1"],"net":"VBUS"},{"op":"connect","pins":["ldo.GND","cin.2"],"net":"GND"}]
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"ops": "<ops>"
},
"name": "sch_apply"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ops | Yes | Ordered list of op objects (see description). | |
| sheet | No | Sub-sheet file or sheet name (default: root sheet). | |
| layout | No | auto (default): a sheet only Copper arranged is re-drawn as functional blocks after a batch without at/rot (netlist proven identical); keep: never; pro: always try. | |
| verify | No | Run ERC + netlist connectivity check after writing. Default true. | |
| dry_run | No | Validate and report what would change without writing. | |
| preview | No | attach a PNG (default false) | |
| project | No | project path (default: active) | |
| while_open | No | refuse (default) | revert |