feat: add set_footprint_type tool for placement attribute control
Adds a `set_footprint_type` MCP tool to set a placed footprint's placement type (through_hole / smd / unspecified) plus the optional exclude_from_pos_files / exclude_from_bom / not_in_schematic flags. These attributes gate inclusion in pick-and-place (.pos) exports and were previously unreachable: edit_component only handled reference/value/footprint and get_component_properties did not report the placement type at all. - python/commands/component.py: SWIG (pcbnew) handler via Set/GetAttributes + the dedicated exclusion setters; extends get_component_properties to report a human-readable `type` plus the three exclusion flags. - python/kicad_interface.py: IPC (kipy) handler setting attributes.mounting_style and the exclusion fields over the proto API with begin_commit/update_items/push_commit so changes are live in the KiCAD UI; registered in the command map, the IPC handler map, and the realtime/IPC whitelist; SWIG fallback on proto error. - src/tools/component.ts: tool registration with zod schema. - tests/test_set_footprint_type.py: 26 unit tests over both backends plus the extended get_component_properties response. - pyproject.toml: add `fitz` (PyMuPDF) to mypy ignore_missing_imports overrides; pre-existing gap that fails mypy on any edit to files importing it (board/view.py, kicad_interface.py). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -202,6 +202,59 @@ export function registerComponentTools(server: McpServer, callKicadScript: Comma
|
||||
},
|
||||
);
|
||||
|
||||
// ------------------------------------------------------
|
||||
// Set Footprint Type Tool
|
||||
// ------------------------------------------------------
|
||||
server.tool(
|
||||
"set_footprint_type",
|
||||
"Set the placement type (through_hole / smd / unspecified) and optional exclusion flags on a placed PCB footprint. The placement type controls whether the footprint is included in pick-and-place (.pos) output files. Use exclude_from_pos_files to suppress a footprint from .pos exports without changing its type.",
|
||||
{
|
||||
reference: z.string().describe("Reference designator of the footprint (e.g. 'R1', 'U3')"),
|
||||
type: z
|
||||
.enum(["smd", "through_hole", "unspecified"])
|
||||
.describe(
|
||||
"Placement type: 'smd' for surface-mount, 'through_hole' for PTH components, 'unspecified' to clear both bits (e.g. for board-only or mechanically-placed items)",
|
||||
),
|
||||
exclude_from_pos_files: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe(
|
||||
"When true, suppress this footprint from pick-and-place (.pos) exports. Omit to leave the current setting unchanged.",
|
||||
),
|
||||
exclude_from_bom: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe(
|
||||
"When true, suppress this footprint from BoM exports. Omit to leave the current setting unchanged.",
|
||||
),
|
||||
not_in_schematic: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe(
|
||||
"When true, marks the footprint as board-only (no corresponding schematic symbol). Omit to leave the current setting unchanged.",
|
||||
),
|
||||
},
|
||||
async ({ reference, type, exclude_from_pos_files, exclude_from_bom, not_in_schematic }) => {
|
||||
logger.debug(`Setting footprint type for: ${reference} -> ${type}`);
|
||||
const result = await callKicadScript("set_footprint_type", {
|
||||
reference,
|
||||
type,
|
||||
exclude_from_pos_files,
|
||||
exclude_from_bom,
|
||||
not_in_schematic,
|
||||
});
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: JSON.stringify(result),
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
// ------------------------------------------------------
|
||||
// Find Component Tool
|
||||
// ------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user