run_kicad_script
Run Python code with KiCad's API pre-loaded to perform custom actions on live PCB or board files when built-in tools fall short.
Instructions
Execute Python with the KiCad API pre-imported. Use this for anything the curated tools do not cover.
Available names: kicad (live KiCad client), board (open board, or None),
kipy, pcbnew, and sexpr for KiCad file parsing.
Print output is captured; assign to result to return a value.
This runs arbitrary local code with your privileges. Do not import kipy.schematic - it is broken in kipy 0.7.1 and KiCad 10 has no schematic API anyway.
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": {
"code": "<code>"
},
"name": "run_kicad_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeout | No |