Skip to main content
Glama

insert_child

Insert a child node into a parent node in Figma to organize design elements. Specify parent and child IDs with optional index placement.

Instructions

Insert a child node inside a parent node in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parentIdYesID of the parent node where the child will be inserted
childIdYesID of the child node to insert
indexNoOptional index where to insert the child (if not specified, it will be added at the end)

Implementation Reference

  • The main handler function that implements the logic for the 'insert_child' tool. It forwards the parameters to the Figma plugin via sendCommandToFigma and formats the response.
    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)}` } ] }; } }
  • Zod schema defining the input parameters for the insert_child tool: parentId, childId, and optional index.
    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)") },
  • The server.tool() call that registers the 'insert_child' tool with MCP server, including name, description, input schema, and handler function.
    "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)}` } ] }; } } );
  • Higher-level registration call that invokes registerCreationTools(server), which includes the insert_child tool registration.
    registerCreationTools(server);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/agenisea/cc-fig-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server