create_component_instance
Generate a new instance of a Figma component to replicate and modify design elements programmatically using Cursor AI’s integration.
Instructions
Create an instance of a component in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/talk_to_figma_mcp/server.ts:1204-1240 (registration)Registration of the MCP tool 'create_component_instance', including input schema (componentKey: string, x: number, y: number) and handler function that proxies the creation request to the Figma plugin via sendCommandToFigma websocket function, returning the result or error.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) }`, }, ], }; } } );
- The handler function implementing the logic for the 'create_component_instance' tool. It calls sendCommandToFigma to delegate the actual component instance creation to the Figma plugin and formats the response as MCP content.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) }`, }, ], }; } }
- Zod input schema for the 'create_component_instance' tool defining parameters: componentKey (string), x (number), y (number).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 }) => {