From 094ef3d6fe0d3ab9a73c3ebb63840d725ac9e1c0 Mon Sep 17 00:00:00 2001 From: Abhishek Mittal Date: Mon, 23 Mar 2026 14:33:32 +0530 Subject: [PATCH] :sparkles: Add 'page' shapeId to MCP export_shape for full-page snapshot (#8693) Add support for 'page' as a special shapeId value in the MCP export_shape tool. It resolves to penpot.root, exporting the entire current page as a PNG or SVG snapshot. Previously only 'selection' and explicit shape IDs were supported. The new 'page' shortcut is useful for AI agents needing a bird's-eye view of the design without having to know a specific shape ID. Closes https://github.com/penpot/penpot/issues/8689 Signed-off-by: Abhishek Mittal --- CHANGES.md | 1 + mcp/packages/server/src/tools/ExportShapeTool.ts | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 58e3043923..33bf62347d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -85,6 +85,7 @@ ## 2.13.0 ### :heart: Community contributions (Thank you!) +- Add 'page' special shapeId to MCP export_shape tool for full-page snapshots [Github #8689](https://github.com/penpot/penpot/issues/8689) - Fix mask issues with component swap (by @dfelinto) [Github #7675](https://github.com/penpot/penpot/issues/7675) diff --git a/mcp/packages/server/src/tools/ExportShapeTool.ts b/mcp/packages/server/src/tools/ExportShapeTool.ts index d032b0b770..7b8ceed4a6 100644 --- a/mcp/packages/server/src/tools/ExportShapeTool.ts +++ b/mcp/packages/server/src/tools/ExportShapeTool.ts @@ -16,8 +16,8 @@ export class ExportShapeArgs { .string() .min(1, "shapeId cannot be empty") .describe( - "Identifier of the shape to export. Use the special identifier 'selection' to " + - "export the first shape currently selected by the user." + "Identifier of the shape to export. " + + "Special identifiers you can use: 'selection' (first shape currently selected by the user), 'page' (entire current page)" ), format: z.enum(["svg", "png"]).default("png").describe("The output format, either 'png' (default) or 'svg'."), mode: z @@ -71,7 +71,7 @@ export class ExportShapeTool extends Tool { public getToolDescription(): string { let description = "Exports a shape (or a shape's image fill) from the Penpot design to a PNG or SVG image, " + - "such that you can get an impression of what it looks like. "; + "such that you can get an impression of what it looks like."; if (this.mcpServer.isFileSystemAccessEnabled()) { description += "\nAlternatively, you can save it to a file."; } @@ -88,6 +88,8 @@ export class ExportShapeTool extends Tool { let shapeCode: string; if (args.shapeId === "selection") { shapeCode = `penpot.selection[0]`; + } else if (args.shapeId === "page") { + shapeCode = `penpot.root`; } else { shapeCode = `penpotUtils.findShapeById("${args.shapeId}")`; }