Skip to main content
Glama

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
NameRequiredDescriptionDefault
nodeIdYesThe ID of the node to modify
variableIdYesThe ID of the color variable to bind
fillIndexNoIndex 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)") },
  • 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)}` } ] }; } }

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/agenisea/cc-fig-mcp'

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