mirror of
https://github.com/penpot/penpot.git
synced 2026-03-26 21:31:24 +01:00
✨ 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 <abhishekmittaloffice@gmail.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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<ExportShapeArgs> {
|
||||
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<ExportShapeArgs> {
|
||||
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}")`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user