Skip to main content
Glama

set_instance_overrides

Apply copied component overrides to selected instances, ensuring target instances adopt the source component with all copied properties automatically.

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

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {}, "type": "object" }

Implementation Reference

  • Registration of the MCP tool 'set_instance_overrides'. Includes the tool name, description, input schema (sourceInstanceId and targetNodeIds), and the handler function that proxies the command to the Figma plugin via sendCommandToFigma and formats the response.
    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 set_instance_overrides Figma plugin command, used in the tool handler for type casting and response processing.
    interface setInstanceOverridesResult { success: boolean; message: string; totalCount?: number; results?: Array<{ success: boolean; instanceId: string; instanceName: string; appliedCount?: number; message?: string; }>; }
  • The handler function for the set_instance_overrides tool. Sends the command to the Figma plugin, type-casts the result, processes success/failure, and returns formatted MCP content response.
    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)}` } ] }; } }
  • MCP prompt that provides guidance on using get_instance_overrides and set_instance_overrides tools to swap overrides between component instances.
    server.prompt( "swap_overrides_instances", "Guide to swap instance overrides between instances", (extra) => { return { messages: [ { role: "assistant", content: { type: "text", text: `# Swap Component Instance and Override Strategy ## Overview This strategy enables transferring content and property overrides from a source instance to one or more target instances in Figma, maintaining design consistency while reducing manual work. ## Step-by-Step Process ### 1. Selection Analysis - Use \`get_selection()\` to identify the parent component or selected instances - For parent components, scan for instances with \`scan_nodes_by_types({ nodeId: "parent-id", types: ["INSTANCE"] })\` - Identify custom slots by name patterns (e.g. "Custom Slot*" or "Instance Slot") or by examining text content - Determine which is the source instance (with content to copy) and which are targets (where to apply content) ### 2. Extract Source Overrides - Use \`get_instance_overrides()\` to extract customizations from the source instance - This captures text content, property values, and style overrides - Command syntax: \`get_instance_overrides({ nodeId: "source-instance-id" })\` - Look for successful response like "Got component information from [instance name]" ### 3. Apply Overrides to Targets - Apply captured overrides using \`set_instance_overrides()\` - Command syntax: \`\`\` set_instance_overrides({ sourceInstanceId: "source-instance-id", targetNodeIds: ["target-id-1", "target-id-2", ...] }) \`\`\` ### 4. Verification - Verify results with \`get_node_info()\` or \`read_my_design()\` - Confirm text content and style overrides have transferred successfully ## Key Tips - Always join the appropriate channel first with \`join_channel()\` - When working with multiple targets, check the full selection with \`get_selection()\` - Preserve component relationships by using instance overrides rather than direct text manipulation`, }, }, ], description: "Strategy for transferring overrides between component instances in Figma", }; }

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

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