feat: add export_sch_svg tool (kicad-cli, schematic SVG)

New MCP tool `export_sch_svg` wrapping `kicad-cli sch export svg`: outputs
one SVG per page into a directory. Exposes drawing-sheet override, theme,
B&W, exclude-drawing-sheet, default-font, no-background-color, and page
selection. 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 10:59:16 -04:00
parent b257b7276d
commit 95f803900d
3 changed files with 122 additions and 0 deletions

View File

@@ -1159,5 +1159,46 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
},
);
// ------------------------------------------------------
// Export Schematic SVG Tool (kicad-cli, full option set)
// ------------------------------------------------------
server.tool(
"export_sch_svg",
"Export a schematic to SVG via kicad-cli (`sch export svg`), one SVG per page into a directory. Exposes drawing-sheet override, theme, black-and-white, exclude-drawing-sheet, default-font, no-background-color, and page selection. schematicPath is REQUIRED.",
{
schematicPath: z.string().describe("Path to the .kicad_sch (required)"),
outputDir: z.string().describe("Output directory for the SVG 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"),
theme: z.string().optional().describe("Color theme to use (default: schematic settings)"),
blackAndWhite: z.boolean().optional().describe("Black and white only"),
excludeDrawingSheet: z.boolean().optional().describe("No drawing sheet"),
defaultFont: z.string().optional().describe("Default font name"),
noBackgroundColor: z
.boolean()
.optional()
.describe("Avoid setting a background color (regardless of theme)"),
pages: z
.string()
.optional()
.describe("Comma list of page numbers to print (blank = all pages)"),
},
async (args) => {
logger.debug(`Exporting schematic SVG to: ${args.outputDir}`);
const result = await callKicadScript("export_sch_svg", args);
return {
content: [
{
type: "text",
text: JSON.stringify(result),
},
],
};
},
);
logger.info("Export tools registered");
}