create_component_instance
Create an instance of a Figma component at specified coordinates to integrate design elements into your workspace.
Instructions
Create an instance of a component in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| componentKey | Yes | Key of the component to instantiate | |
| x | Yes | X position | |
| y | Yes | Y position |
Implementation Reference
- The handler function for the MCP tool 'create_component_instance'. It sends the command to Figma using sendCommandToFigma and returns the result as text content or an error message.async ({ componentKey, x, y }) => { try { const result = await sendCommandToFigma("create_component_instance", { componentKey, x, y, }); const typedResult = result as any; return { content: [ { type: "text", text: JSON.stringify(typedResult), } ] } } catch (error) { return { content: [ { type: "text", text: `Error creating component instance: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );
- Input schema for the tool using Zod validators with descriptions for componentKey, x, and y parameters.{ componentKey: z.string().describe("Key of the component to instantiate"), x: z.number().describe("X position"), y: z.number().describe("Y position"), },
- src/talk_to_figma_mcp/tools/component-tools.ts:12-47 (registration)Direct registration of the 'create_component_instance' tool on the MCP server using server.tool(), including name, description, schema, and handler.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 any; return { content: [ { type: "text", text: JSON.stringify(typedResult), } ] } } catch (error) { return { content: [ { type: "text", text: `Error creating component instance: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );
- src/talk_to_figma_mcp/tools/index.ts:17-17 (registration)Invocation of registerComponentTools within the central registerTools function, which registers all tools including create_component_instance.registerComponentTools(server);
- The 'create_component_instance' command is included in the FigmaCommand union type used for typing internal WebSocket commands to Figma.| "create_component_instance"