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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action ('insert') which implies mutation, but doesn't cover critical aspects like permissions needed, whether the operation is reversible, error conditions (e.g., invalid IDs), or what happens to existing child nodes. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with zero wasted content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks behavioral context (permissions, reversibility, errors), doesn't explain the result of the insertion, and provides no usage guidance. While concise, it doesn't compensate for the missing structured information.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear parameter documentation in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema (e.g., it doesn't explain ID formats, index behavior beyond 'end', or relationships between parent and child nodes). This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('insert') and target ('a child node inside a parent node in Figma'), which is specific and unambiguous. However, it doesn't differentiate from sibling tools like 'move_node' or 'group_nodes' that also manipulate node relationships, leaving some ambiguity about when this exact insertion operation is needed versus alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., whether nodes must exist), exclusions, or compare it to similar tools like 'move_node' or 'group_nodes' in the sibling list, leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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