set_instance_overrides
Apply copied component overrides to selected instances in Figma, swapping them to match the source component's properties.
Instructions
Apply previously copied overrides to selected component instances. Target instances will be swapped to the source component and all copied override properties will be applied.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sourceInstanceId | Yes | ID of the source component instance | |
| targetNodeIds | Yes | Array of target instance IDs. Currently selected instances will be used. |
Implementation Reference
- The handler function that executes the 'set_instance_overrides' tool. It sends the sourceInstanceId and targetNodeIds to the Figma plugin via sendCommandToFigma, processes the result typed as setInstanceOverridesResult, and returns formatted content blocks based on success or failure.async ({ sourceInstanceId, targetNodeIds }) => { try { const result = await sendCommandToFigma("set_instance_overrides", { sourceInstanceId: sourceInstanceId, targetNodeIds: targetNodeIds || [] }); const typedResult = result as setInstanceOverridesResult; if (typedResult.success) { const successCount = typedResult.results?.filter(r => r.success).length || 0; return { content: [ { type: "text", text: `Successfully applied ${typedResult.totalCount || 0} overrides to ${successCount} instances.` } ] }; } else { return { content: [ { type: "text", text: `Failed to set instance overrides: ${typedResult.message}` } ] }; } } catch (error) { return { content: [ { type: "text", text: `Error setting instance overrides: ${error instanceof Error ? error.message : String(error)}` } ] }; } }
- Zod schema for input validation of the 'set_instance_overrides' tool parameters: sourceInstanceId (string) and targetNodeIds (array of strings).{ sourceInstanceId: z.string().describe("ID of the source component instance"), targetNodeIds: z.array(z.string()).describe("Array of target instance IDs. Currently selected instances will be used.") },
- src/talk_to_figma_mcp/server.ts:1280-1326 (registration)Registration of the 'set_instance_overrides' tool on the MCP server using server.tool(), including name, description, input schema, and handler function.server.tool( "set_instance_overrides", "Apply previously copied overrides to selected component instances. Target instances will be swapped to the source component and all copied override properties will be applied.", { sourceInstanceId: z.string().describe("ID of the source component instance"), targetNodeIds: z.array(z.string()).describe("Array of target instance IDs. Currently selected instances will be used.") }, async ({ sourceInstanceId, targetNodeIds }) => { try { const result = await sendCommandToFigma("set_instance_overrides", { sourceInstanceId: sourceInstanceId, targetNodeIds: targetNodeIds || [] }); const typedResult = result as setInstanceOverridesResult; if (typedResult.success) { const successCount = typedResult.results?.filter(r => r.success).length || 0; return { content: [ { type: "text", text: `Successfully applied ${typedResult.totalCount || 0} overrides to ${successCount} instances.` } ] }; } else { return { content: [ { type: "text", text: `Failed to set instance overrides: ${typedResult.message}` } ] }; } } catch (error) { return { content: [ { type: "text", text: `Error setting instance overrides: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- TypeScript interface defining the expected result structure from the Figma plugin for set_instance_overrides.interface setInstanceOverridesResult { success: boolean; message: string; totalCount?: number; results?: Array<{ success: boolean; instanceId: string; instanceName: string; appliedCount?: number; message?: string; }>; }