Skip to main content
Glama

set_fill_color

Change the fill color of a Figma design element by specifying RGB values and optional transparency. Use this tool to modify visual appearance in real-time through the CC Fig MCP server.

Instructions

Set the fill color of a node in Figma. Alpha component defaults to 1 (fully opaque) if not specified. Use alpha 0 for fully transparent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the node to modify
rYesRed component (0-1)
gYesGreen component (0-1)
bYesBlue component (0-1)
aNoAlpha component (0-1, defaults to 1 if not specified)

Implementation Reference

  • Executes the set_fill_color tool: validates inputs, applies color defaults, sends command to Figma WebSocket, returns success/error text response.
    async ({ nodeId, r, g, b, a }) => {
      try {
        // Additional validation: Ensure RGB values are provided (they should not be undefined)
        if (r === undefined || g === undefined || b === undefined) {
          throw new Error("RGB components (r, g, b) are required and cannot be undefined");
        }
        
        // Apply default values safely - preserves opacity 0 for transparency
        const colorInput: Color = { r, g, b, a };
        const colorWithDefaults = applyColorDefaults(colorInput);
        
        const result = await sendCommandToFigma("set_fill_color", {
          nodeId,
          color: colorWithDefaults,
        });
        const typedResult = result as { name: string };
        return {
          content: [
            {
              type: "text",
              text: `Set fill color of node "${typedResult.name}" to RGBA(${r}, ${g}, ${b}, ${colorWithDefaults.a})`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error setting fill color: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • Input schema using Zod for tool parameters: nodeId (string), r,g,b (0-1 numbers), optional a (0-1).
    {
      nodeId: z.string().describe("The ID of the node to modify"),
      r: z.number().min(0).max(1).describe("Red component (0-1)"),
      g: z.number().min(0).max(1).describe("Green component (0-1)"),
      b: z.number().min(0).max(1).describe("Blue component (0-1)"),
      a: z.number().min(0).max(1).optional().describe("Alpha component (0-1, defaults to 1 if not specified)"),
    },
  • Registers the set_fill_color tool on the MCP server with name, description, input schema, and handler function.
      "set_fill_color",
      "Set the fill color of a node in Figma. Alpha component defaults to 1 (fully opaque) if not specified. Use alpha 0 for fully transparent.",
      {
        nodeId: z.string().describe("The ID of the node to modify"),
        r: z.number().min(0).max(1).describe("Red component (0-1)"),
        g: z.number().min(0).max(1).describe("Green component (0-1)"),
        b: z.number().min(0).max(1).describe("Blue component (0-1)"),
        a: z.number().min(0).max(1).optional().describe("Alpha component (0-1, defaults to 1 if not specified)"),
      },
      async ({ nodeId, r, g, b, a }) => {
        try {
          // Additional validation: Ensure RGB values are provided (they should not be undefined)
          if (r === undefined || g === undefined || b === undefined) {
            throw new Error("RGB components (r, g, b) are required and cannot be undefined");
          }
          
          // Apply default values safely - preserves opacity 0 for transparency
          const colorInput: Color = { r, g, b, a };
          const colorWithDefaults = applyColorDefaults(colorInput);
          
          const result = await sendCommandToFigma("set_fill_color", {
            nodeId,
            color: colorWithDefaults,
          });
          const typedResult = result as { name: string };
          return {
            content: [
              {
                type: "text",
                text: `Set fill color of node "${typedResult.name}" to RGBA(${r}, ${g}, ${b}, ${colorWithDefaults.a})`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting fill color: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Utility function called by the handler to apply default alpha=1 to the color object if a is undefined.
    export function applyColorDefaults(color: Color): ColorWithDefaults {
      return {
        r: color.r,
        g: color.g,
        b: color.b,
        a: applyDefault(color.a, FIGMA_DEFAULTS.color.opacity)
      };
    }
  • TypeScript interface for Color used in the handler for colorInput.
    export interface Color {
      r: number;
      g: number;
      b: number;
      a?: number;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only mentions default alpha behavior. It doesn't disclose whether this is a destructive mutation, permission requirements, error handling, rate limits, or what happens to existing fill properties. For a mutation tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences with zero waste. The first states the purpose, the second provides important behavioral detail about defaults. Every sentence earns its place and information is front-loaded appropriately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description provides basic purpose and default behavior but lacks important context about mutation effects, error conditions, return values, and relationship to sibling tools. It's minimally adequate but has clear gaps for a tool that modifies visual properties.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minor value by clarifying the default alpha behavior (a=1 if not specified) and the meaning of alpha=0, but doesn't provide additional semantic context beyond what's in the schema. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Set the fill color'), target resource ('of a node in Figma'), and distinguishes from siblings like 'set_stroke_color' by focusing on fill rather than stroke. It provides a complete purpose statement without tautology.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for color modification but doesn't explicitly state when to use this tool versus alternatives like 'set_effects' or 'set_effect_style_id'. No guidance on prerequisites, error conditions, or specific scenarios where this tool is preferred over others is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.