feat: add export_pcb_pdf tool (kicad-cli, full layer-plot PDF)
New MCP tool `export_pcb_pdf` wrapping `kicad-cli pcb export pdf`: exposes the full layer-plot surface (layer/common-layer lists, mirror, refdes/value exclusion, border+title, soldermask subtraction, the four DNP fab-layer modes, negative, B&W, theme, drill-shape, and the single/separate/multipage output modes). Rich CLI sibling of the existing SWIG export_pdf (left untouched). Reads the saved .kicad_pcb. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -648,5 +648,76 @@ export function registerExportTools(server: McpServer, callKicadScript: CommandF
|
||||
},
|
||||
);
|
||||
|
||||
// ------------------------------------------------------
|
||||
// Export PCB PDF Tool (kicad-cli, full layer-plot option set)
|
||||
// ------------------------------------------------------
|
||||
server.tool(
|
||||
"export_pcb_pdf",
|
||||
"Plot the PCB layout to PDF via kicad-cli, exposing the full layer-plot option set (layer + common-layer lists, mirror, refdes/value exclusion, border+title, soldermask subtraction, DNP fab-layer modes, negative, black-and-white, theme, drill shape, and single/separate/multipage output modes). Rich CLI sibling of export_pdf. Reads the last SAVED state of the .kicad_pcb.",
|
||||
{
|
||||
outputPath: z.string().describe("Output PDF file path (or directory in separate mode)"),
|
||||
boardPath: z.string().optional().describe("Path to the .kicad_pcb (default: current board)"),
|
||||
layers: z
|
||||
.array(z.string())
|
||||
.optional()
|
||||
.describe("Layers to plot, untranslated names e.g. ['F.Cu','B.Cu','Edge.Cuts']"),
|
||||
commonLayers: z
|
||||
.array(z.string())
|
||||
.optional()
|
||||
.describe("Layers to include on every plot (e.g. ['Edge.Cuts'])"),
|
||||
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"),
|
||||
mirror: z.boolean().optional().describe("Mirror the board (to show bottom layers)"),
|
||||
excludeRefdes: z.boolean().optional().describe("Exclude reference designator text"),
|
||||
excludeValue: z.boolean().optional().describe("Exclude value text"),
|
||||
includeBorderTitle: z.boolean().optional().describe("Include the border and title block"),
|
||||
subtractSoldermask: z.boolean().optional().describe("Subtract soldermask from silkscreen"),
|
||||
sketchPadsOnFabLayers: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Draw pad outlines and numbers on fab layers"),
|
||||
hideDnpFootprintsOnFabLayers: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Don't plot DNP footprint text/graphics on fab layers"),
|
||||
sketchDnpFootprintsOnFabLayers: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Plot DNP footprints in sketch mode on fab layers"),
|
||||
crossoutDnpFootprintsOnFabLayers: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Plot an 'X' over DNP footprint courtyards and strike out their refdes"),
|
||||
negative: z.boolean().optional().describe("Plot as negative"),
|
||||
blackAndWhite: z.boolean().optional().describe("Black and white only"),
|
||||
theme: z.string().optional().describe("Color theme to use (default: PCB editor settings)"),
|
||||
drillShapeOpt: z
|
||||
.number()
|
||||
.optional()
|
||||
.describe("Pad/via drill shape option (0 none, 1 small, 2 actual; default 2)"),
|
||||
modeSingle: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Single file; output path is full path; LAYER_LIST controls all layers"),
|
||||
modeSeparate: z.boolean().optional().describe("Plot the layers to individual PDF files"),
|
||||
modeMultipage: z.boolean().optional().describe("Plot the layers to a single multi-page PDF"),
|
||||
},
|
||||
async (args) => {
|
||||
logger.debug(`Exporting PCB PDF to: ${args.outputPath}`);
|
||||
const result = await callKicadScript("export_pcb_pdf", args);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: JSON.stringify(result),
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
logger.info("Export tools registered");
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ export const toolCategories: ToolCategory[] = [
|
||||
"export_ipcd356",
|
||||
"export_gencad",
|
||||
"export_pos",
|
||||
"export_pcb_pdf",
|
||||
"export_pdf",
|
||||
"export_svg",
|
||||
"export_3d",
|
||||
|
||||
Reference in New Issue
Block a user