group_nodes
Combine multiple Figma design elements into a single group for easier organization and manipulation using node IDs.
Instructions
Group nodes in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeIds | Yes | Array of IDs of the nodes to group | |
| name | No | Optional name for the group |
Implementation Reference
- The main handler logic for the 'group_nodes' MCP tool. It forwards the parameters to Figma's 'group_nodes' command using sendCommandToFigma, processes the response, and returns a formatted success or error message.async ({ nodeIds, name }) => { try { const result = await sendCommandToFigma("group_nodes", { nodeIds, name }); const typedResult = result as { id: string, name: string, type: string, children: Array<{ id: string, name: string, type: string }> }; return { content: [ { type: "text", text: `Nodes successfully grouped into "${typedResult.name}" with ID: ${typedResult.id}. The group contains ${typedResult.children.length} elements.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error grouping nodes: ${error instanceof Error ? error.message : String(error)}` } ] }; } }
- Input schema validation using Zod for the 'group_nodes' tool parameters.{ nodeIds: z.array(z.string()).describe("Array of IDs of the nodes to group"), name: z.string().optional().describe("Optional name for the group") },
- src/talk_to_figma_mcp/tools/creation-tools.ts:424-464 (registration)Registration of the 'group_nodes' MCP tool on the server using server.tool(), specifying name, description, input schema, and handler function.server.tool( "group_nodes", "Group nodes in Figma", { nodeIds: z.array(z.string()).describe("Array of IDs of the nodes to group"), name: z.string().optional().describe("Optional name for the group") }, async ({ nodeIds, name }) => { try { const result = await sendCommandToFigma("group_nodes", { nodeIds, name }); const typedResult = result as { id: string, name: string, type: string, children: Array<{ id: string, name: string, type: string }> }; return { content: [ { type: "text", text: `Nodes successfully grouped into "${typedResult.name}" with ID: ${typedResult.id}. The group contains ${typedResult.children.length} elements.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error grouping nodes: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );