set_fill_variable
Bind a color variable to a node's fill for theme-compatible designs instead of hardcoded RGB values.
Instructions
Bind a color variable to a node's fill. Use this for theme-compatible colors instead of hardcoded RGB values.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the node to modify | |
| variableId | Yes | The ID of the color variable to bind | |
| fillIndex | No | Index of the fill to modify (default: 0) |
Implementation Reference
- The execution handler for the 'set_fill_variable' tool. It sends a websocket command to Figma to bind the specified color variable to the node's fill (at optional fillIndex), then returns a success or error message.async ({ nodeId, variableId, fillIndex }) => { try { const result = await sendCommandToFigma("set_fill_variable", { nodeId, variableId, fillIndex: fillIndex ?? 0 }); const typedResult = result as { name: string; variableName: string }; return { content: [ { type: "text", text: `Successfully bound variable "${typedResult.variableName}" to fill of node "${typedResult.name}"` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error setting fill variable: ${error instanceof Error ? error.message : String(error)}` } ] }; } }
- Zod input schema for the 'set_fill_variable' tool, validating nodeId (string), variableId (string), and optional fillIndex (number).{ nodeId: z.string().describe("The ID of the node to modify"), variableId: z.string().describe("The ID of the color variable to bind"), fillIndex: z.number().optional().describe("Index of the fill to modify (default: 0)") },
- src/talk_to_figma_mcp/tools/modification-tools.ts:445-479 (registration)Full registration of the 'set_fill_variable' MCP tool on the server, including name, description, input schema, and handler function.server.tool( "set_fill_variable", "Bind a color variable to a node's fill. Use this for theme-compatible colors instead of hardcoded RGB values.", { nodeId: z.string().describe("The ID of the node to modify"), variableId: z.string().describe("The ID of the color variable to bind"), fillIndex: z.number().optional().describe("Index of the fill to modify (default: 0)") }, async ({ nodeId, variableId, fillIndex }) => { try { const result = await sendCommandToFigma("set_fill_variable", { nodeId, variableId, fillIndex: fillIndex ?? 0 }); const typedResult = result as { name: string; variableName: string }; return { content: [ { type: "text", text: `Successfully bound variable "${typedResult.variableName}" to fill of node "${typedResult.name}"` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error setting fill variable: ${error instanceof Error ? error.message : String(error)}` } ] }; } }