Skip to main content
Glama
yhc984

Talk to Figma MCP

by yhc984

create_component_instance

Create a new instance of a Figma component at specified coordinates to reuse design elements across your project.

Instructions

Create an instance of a component in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentKeyYesKey of the component to instantiate
xYesX position
yYesY position

Implementation Reference

  • The core handler function that implements the create_component_instance tool logic using Figma's API to import a component by key and create an instance at the specified position on the current page.
    async function createComponentInstance(params) {
      const { componentKey, x = 0, y = 0 } = params || {};
    
      if (!componentKey) {
        throw new Error("Missing componentKey parameter");
      }
    
      try {
        const component = await figma.importComponentByKeyAsync(componentKey);
        const instance = component.createInstance();
    
        instance.x = x;
        instance.y = y;
    
        figma.currentPage.appendChild(instance);
    
        return {
          id: instance.id,
          name: instance.name,
          x: instance.x,
          y: instance.y,
          width: instance.width,
          height: instance.height,
          componentId: instance.componentId,
        };
      } catch (error) {
        throw new Error(`Error creating component instance: ${error.message}`);
      }
    }
  • MCP server tool registration for 'create_component_instance', including input schema (componentKey, x, y), description, and proxy handler that forwards the command to the Figma plugin via WebSocket.
    server.tool(
      "create_component_instance",
      "Create an instance of a component in Figma",
      {
        componentKey: z.string().describe("Key of the component to instantiate"),
        x: z.number().describe("X position"),
        y: z.number().describe("Y position")
      },
      async ({ componentKey, x, y }) => {
        try {
          const result = await sendCommandToFigma('create_component_instance', { componentKey, x, y });
          const typedResult = result as { name: string, id: string };
          return {
            content: [
              {
                type: "text",
                text: `Created component instance "${typedResult.name}" with ID: ${typedResult.id}`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error creating component instance: ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
  • Zod schema defining the input parameters for the create_component_instance MCP tool.
    {
      componentKey: z.string().describe("Key of the component to instantiate"),
      x: z.number().describe("X position"),
      y: z.number().describe("Y position")
    },
  • Dispatch case in the Figma plugin's command handler that routes 'create_component_instance' calls to the implementation function.
        case "create_component_instance":
          return await createComponentInstance(params);
        case "export_node_as_image":
          return await exportNodeAsImage(params);
        case "execute_code":
          return await executeCode(params);
        case "set_corner_radius":
          return await setCornerRadius(params);
        default:
          throw new Error(`Unknown command: ${command}`);
      }
    }
  • TypeScript union type including 'create_component_instance' as a valid Figma command.
    type FigmaCommand =
      | 'get_document_info'
      | 'get_selection'
      | 'get_node_info'
      | 'create_rectangle'
      | 'create_frame'
      | 'create_text'
      | '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'
      | 'execute_code'
      | 'join'
      | 'set_corner_radius';
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. While 'Create' implies a write/mutation operation, the description doesn't specify permissions required, whether this affects the original component, what happens on failure, or what the expected output looks like. For a mutation tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 states exactly what the tool does without any wasted words. It's appropriately sized for a straightforward tool and gets directly to the point with no unnecessary elaboration.

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 insufficient. It doesn't explain what 'creating an instance' means in Figma context, what the tool returns, error conditions, or how this operation fits within the broader Figma workflow. Given the complexity of component instantiation and lack of structured metadata, more contextual information would be helpful.

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?

The input schema has 100% description coverage, with all three parameters clearly documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema descriptions. According to scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.

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 ('Create an instance') and target resource ('component in Figma'), making the tool's purpose immediately understandable. It distinguishes itself from siblings like 'create_frame' or 'create_rectangle' by specifying it's for component instantiation rather than creating new elements from scratch. However, it doesn't explicitly differentiate from 'clone_node' which might have overlapping functionality.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (like needing an existing component), when not to use it, or how it differs from similar tools like 'clone_node' or 'create_frame'. The agent must infer usage context from the tool name alone.

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/yhc984/cursor-talk-to-figma-mcp-main'

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