feat: add export_sch_hpgl tool (kicad-cli, schematic HPGL)

New MCP tool `export_sch_hpgl` wrapping `kicad-cli sch export hpgl`: outputs
one plot per page into a directory. Exposes drawing-sheet override,
exclude-drawing-sheet, default-font, page selection, pen size, and the
origin/scale mode. schematicPath required; directory output uses outputDir.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gavin Colonese
2026-06-12 11:00:05 -04:00
parent cff3addc95
commit c893509993
3 changed files with 116 additions and 0 deletions

View File

@@ -1237,5 +1237,45 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
},
);
// ------------------------------------------------------
// Export Schematic HPGL Tool (kicad-cli, full option set)
// ------------------------------------------------------
server.tool(
"export_sch_hpgl",
"Export a schematic to HPGL via kicad-cli (`sch export hpgl`), one plot per page into a directory. Exposes drawing-sheet override, exclude-drawing-sheet, default-font, page selection, pen size, and the origin/scale mode. schematicPath is REQUIRED.",
{
schematicPath: z.string().describe("Path to the .kicad_sch (required)"),
outputDir: z.string().describe("Output directory for the HPGL files"),
drawingSheet: z.string().optional().describe("Path to a drawing sheet override"),
defineVar: z
.array(z.string())
.optional()
.describe("Project variable overrides as 'KEY=VALUE' strings"),
excludeDrawingSheet: z.boolean().optional().describe("No drawing sheet"),
defaultFont: z.string().optional().describe("Default font name"),
pages: z
.string()
.optional()
.describe("Comma list of page numbers to print (blank = all pages)"),
penSize: z.number().optional().describe("Pen size in mm (default 0.5)"),
origin: z
.number()
.optional()
.describe("Origin and scale: 0 bottom left, 1 centered, 2 page fit, 3 content fit"),
},
async (args) => {
logger.debug(`Exporting schematic HPGL to: ${args.outputDir}`);
const result = await callKicadScript("export_sch_hpgl", args);
return {
content: [
{
type: "text",
text: JSON.stringify(result),
},
],
};
},
);
logger.info("Export tools registered");
}

View File

@@ -74,6 +74,7 @@ export const toolCategories: ToolCategory[] = [
"export_sch_pdf",
"export_sch_svg",
"export_sch_dxf",
"export_sch_hpgl",
"export_pdf",
"export_svg",
"export_3d",