From f5afcde0dece4df120371e2dbc362ff9925bff2c Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Tue, 10 Feb 2026 22:52:56 +0100 Subject: [PATCH] :sparkles: Improve shapeStructure * Add information on component instance (component id, name; main instance id) * Improve JSON result order (children should come last) --- mcp/packages/plugin/src/PenpotUtils.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/mcp/packages/plugin/src/PenpotUtils.ts b/mcp/packages/plugin/src/PenpotUtils.ts index 602ac3327c..d4d3f49967 100644 --- a/mcp/packages/plugin/src/PenpotUtils.ts +++ b/mcp/packages/plugin/src/PenpotUtils.ts @@ -25,7 +25,6 @@ export class PenpotUtils { id: shape.id, name: shape.name, type: shape.type, - children: children, }; // add layout information if present @@ -48,6 +47,23 @@ export class PenpotUtils { }; } + // add component instance information if present + if (shape.isComponentInstance()) { + result.componentInstance = {}; + const component = shape.component(); + if (component) { + result.componentInstance.componentId = component.id; + result.componentInstance.componentName = component.name; + const mainInstance = component.mainInstance(); + if (mainInstance) { + result.componentInstance.mainInstanceId = mainInstance.id; + } + } + } + + // finally, add children (last for more readable nesting order) + result.children = children; + return result; }