add_component_from_library
Place a symbol from a KiCad library into a schematic, applying its fields, pins and flags. Use it to add parts from global or project library tables with grid-aligned connections.
Instructions
Add a symbol of a KiCad symbol library to the schematic.
The library comes from the library tables of the installed KiCad and of the project, as in the symbol chooser of KiCad: a library of the project table replaces a global library with the same name. A derived symbol gets the units, the pins and the drawings of its parents. When the schematic has the symbol in its lib_symbols section, the tool uses that definition. The tool gets the version of the installed KiCad from kicad-cli, to find the global library table.
The placed symbol gets the fields of the library symbol (Datasheet, Description, user fields) at their library positions, the flags exclude_from_sim, in_bom, on_board and in_pos_files of the library symbol, and the reference of its sheet path, as KiCad places a symbol. The tool does not move the fields (KiCad: autoplace).
The connection grid is schematic.connection_grid_size of the project file (default 1.27 mm). ERC finds a pin off this grid (endpoint_off_grid).
As the schematic editor of KiCad, the tool removes the part of a wire between two pins of the new symbol, and adds a junction where a pin is in the middle of a wire. The output tells each junction and each changed wire.
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": {
"file_path": "<file_path>",
"library_name": "<library_name>",
"symbol_name": "<symbol_name>",
"reference": "<reference>",
"value": "<value>"
},
"name": "add_component_from_library"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | No | ||
| y | No | ||
| unit | No | The unit, from 1 to the number of units of the symbol. | |
| value | Yes | The text of the Value field. | |
| file_path | Yes | The .kicad_sch file. | |
| footprint | No | The footprint. Empty: the footprint of the library symbol. | |
| reference | Yes | The reference, for example "R1". | |
| sheet_path | No | Only for a sheet file that the hierarchy uses more than one time: the sheet that gets the reference, as the sheet names ("/Power/") or the UUID path. The error lists the sheet paths. | |
| symbol_name | Yes | The symbol name in the library. | |
| library_name | Yes | The library name of the library tables. | |
| snap_to_grid | No | True: move the symbol to the nearest position that puts its pins on the connection grid. When the move takes a pin away from a connection point of the sheet (a pin, a wire, a label), the symbol stays at x, y. False: use x, y as they are. The output tells the pins off the grid. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |