Skip to main content
Glama
arinspunk

Claude Talk to Figma MCP

by arinspunk

set_fill_color

Change the fill color of Figma design elements using RGB values with optional transparency control to customize visual appearance.

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

  • The async handler function that executes the 'set_fill_color' tool logic: validates RGB, applies color defaults, sends Figma command, returns 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)}`,
            },
          ],
        };
      }
    }
  • Registers the 'set_fill_color' MCP tool with server.tool, including description, Zod input schema, and handler.
    server.tool(
      "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)}`,
              },
            ],
          };
        }
      }
    );
  • Zod schema defining input parameters for the set_fill_color tool.
    {
      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)"),
    },
  • TypeScript interface for Color type used in the tool handler.
    export interface Color {
      r: number;
      g: number;
      b: number;
      a?: number;
    }
  • Utility function to apply default alpha value (1) to Color, preserving explicit 0 for transparency; called in handler.
    export function applyColorDefaults(color: Color): ColorWithDefaults {
      return {
        r: color.r,
        g: color.g,
        b: color.b,
        a: applyDefault(color.a, FIGMA_DEFAULTS.color.opacity)
      };
    }
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.

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/arinspunk/claude-talk-to-figma-mcp'

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