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;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions alpha defaults and transparency effects, which is helpful, but fails to describe critical behaviors: whether this is a mutation (implied by 'Set'), what permissions are needed, if changes are reversible, error conditions (e.g., invalid nodeId), or response format. For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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?

The description is extremely concise and front-loaded, stating the core purpose in the first clause. Both sentences earn their place: the first defines the action, and the second provides essential alpha behavior details. There's no wasted verbiage or redundancy, making it efficient for quick comprehension.

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

Completeness2/5

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

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It covers the basic action and alpha behavior but misses critical context: error handling, response format, permissions, and differentiation from sibling tools. For a tool that modifies visual properties, more behavioral transparency is needed to ensure safe and correct usage.

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 fully documents all parameters (nodeId, r, g, b, a). The description adds minimal value beyond the schema by reiterating the alpha default and explaining transparency, but doesn't provide additional semantic context like color format expectations or nodeId sourcing. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('Set') and resource ('fill color of a node in Figma'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'set_fill_style_id' or 'set_fill_variable', which also modify fill properties, leaving some ambiguity about when to choose this specific tool over alternatives.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions alpha defaults and transparency, but doesn't specify prerequisites (e.g., node must exist), exclusions, or compare it to sibling tools like 'set_fill_style_id' for style-based coloring. This lack of contextual usage information could lead to incorrect tool selection.

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

Install Server

Other Tools

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