insert_child
Add a child node to a parent node in Figma designs to organize layers and structure components.
Instructions
Insert a child node inside a parent node in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parentId | Yes | ID of the parent node where the child will be inserted | |
| childId | Yes | ID of the child node to insert | |
| index | No | Optional index where to insert the child (if not specified, it will be added at the end) |
Implementation Reference
- Full registration block including the handler function for the 'insert_child' MCP tool. The handler sends the insert_child command to Figma's websocket server with the provided parentId, childId, and optional index, types the result, and returns a structured text response indicating success or error.server.tool( "insert_child", "Insert a child node inside a parent node in Figma", { parentId: z.string().describe("ID of the parent node where the child will be inserted"), childId: z.string().describe("ID of the child node to insert"), index: z.number().optional().describe("Optional index where to insert the child (if not specified, it will be added at the end)") }, async ({ parentId, childId, index }) => { try { const result = await sendCommandToFigma("insert_child", { parentId, childId, index }); const typedResult = result as { parentId: string, childId: string, index: number, success: boolean }; return { content: [ { type: "text", text: `Child node with ID: ${typedResult.childId} successfully inserted into parent node with ID: ${typedResult.parentId}${index !== undefined ? ` at position ${typedResult.index}` : ''}.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error inserting child node: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- TypeScript type definition for FigmaCommand union that includes "insert_child" as a valid command type used throughout the codebase for typing Figma interactions.export type FigmaCommand = | "get_document_info" | "get_selection" | "get_node_info" | "create_rectangle" | "create_frame" | "create_text" | "create_ellipse" | "create_polygon" | "create_star" | "create_vector" | "create_line" | "set_fill_color" | "set_stroke_color" | "move_node" | "resize_node" | "delete_node" | "get_styles" | "get_local_components" | "get_team_components" | "create_component_instance" | "export_node_as_image" | "join" | "set_corner_radius" | "clone_node" | "set_text_content" | "scan_text_nodes" | "set_multiple_text_contents" | "set_auto_layout" | "set_font_name" | "set_font_size" | "set_font_weight" | "set_letter_spacing" | "set_line_height" | "set_paragraph_spacing" | "set_text_case" | "set_text_decoration" | "get_styled_text_segments" | "load_font_async" | "get_remote_components" | "set_effects" | "set_effect_style_id" | "group_nodes" | "ungroup_nodes" | "flatten_node" | "insert_child";
- src/talk_to_figma_mcp/tools/index.ts:15-15 (registration)Higher-level registration call to registerCreationTools(server), which in turn registers the insert_child tool among other creation tools.registerCreationTools(server);