export_bom
Exports the bill of materials from a KiCad schematic as a table or CSV, with optional grouping, variant handling, and DNP exclusion.
Instructions
Give the bill of materials (BOM) of a schematic, as KiCad makes it.
The tool runs "kicad-cli sch export bom" for the full project of the schematic, and gives its lines as a table. Without group_by, each reference is one line. KiCad does not put the power symbols and the symbols that are excluded from the BOM into the BOM.
The units of one package (one reference, U1A and U1B) must have the same Value, MPN, Value_Confirmed and MPN_Confirmed. When they do not, the output starts with an error of the design: the BOM line of the package joins the values, and the joined MPNs look like an MPN and its alternative. Tell the user, and correct the fields in KiCad.
For project_check of datasheet-lens, give output_path and no group_by. Then give the path of the CSV file to project_check (argument bom). For a project with variants (KiCad 10), also give all_variants: then give the list of the files that the tool names to project_check.
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": {
"schematic_path": "<schematic_path>"
},
"name": "export_bom"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | The fields of the BOM, in their order. "*" adds all other fields. A generated field has the form "${QUANTITY}" or "${DNP}". Default: Reference, Value, Footprint, Datasheet, ${QUANTITY}, ${DNP} and "*". | |
| variant | No | The name of a variant of the project (KiCad 10 and later). Empty: the default variant. | |
| group_by | No | The fields whose equal values put symbols into one line. Each name must be an item of fields: a field that "*" adds does not group the symbols. Default: no groups. | |
| exclude_dnp | No | True to remove the symbols that have DNP. | |
| output_path | No | The CSV file to write, as kicad-cli writes it. A relative path is relative to the project directory. The tool does not expand variables. The tool replaces an existing file. Empty: the tool keeps no file. | |
| all_variants | No | True to export the default variant and each variant of the project (KiCad 10 and later), one kicad-cli run and one CSV file for each: the default variant into output_path, the variant X into <stem>-X<suffix> next to it (bom.csv: bom-X.csv). It needs output_path, and gives no tables. Not with variant. | |
| schematic_path | Yes | A .kicad_sch file of the project. The BOM is the BOM of the full project, also for a sub-sheet. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |