Skip to main content
Glama
arinspunk

Claude Talk to Figma MCP

by arinspunk

set_image

Set an image fill on a Figma node from base64-encoded image data. Supports PNG, JPEG, GIF, WebP formats up to ~5MB after decoding. Specify node ID, image data, and optional scale mode (FILL, FIT, CROP, TILE).

Instructions

Set an image fill on a node from base64-encoded image data. Supports PNG, JPEG, GIF, WebP. Max ~5MB after decode.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the node to apply the image fill to
imageDataYesBase64-encoded image data (PNG, JPEG, GIF, or WebP). Max ~5MB after decode.
scaleModeNoHow the image is scaled within the node (default: FILL)

Implementation Reference

  • The 'set_image' tool handler. Registers a server tool that accepts nodeId, base64 imageData, and optional scaleMode, then sends a 'set_image' command to Figma via WebSocket. Returns the node name and image hash on success, or an error message on failure.
    // Set Image Fill Tool
    server.tool(
      "set_image",
      "Set an image fill on a node from base64-encoded image data. Supports PNG, JPEG, GIF, WebP. Max ~5MB after decode.",
      {
        nodeId: z.string().describe("The ID of the node to apply the image fill to"),
        imageData: z.string().max(7_000_000).describe("Base64-encoded image data (PNG, JPEG, GIF, or WebP). Max ~5MB after decode."),
        scaleMode: z.enum(["FILL", "FIT", "CROP", "TILE"]).optional().describe("How the image is scaled within the node (default: FILL)"),
      },
      async ({ nodeId, imageData, scaleMode }) => {
        try {
          const result = await sendCommandToFigma("set_image", {
            nodeId,
            imageData,
            scaleMode: scaleMode || "FILL",
          });
          const typedResult = result as { name: string; imageHash: string };
          return {
            content: [
              {
                type: "text",
                text: `Set image fill on node "${typedResult.name}" with scale mode ${scaleMode || "FILL"} (hash: ${typedResult.imageHash})`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting image fill: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Input schema for the 'set_image' tool: nodeId (string), imageData (base64 string, max 7M chars), scaleMode (optional enum: FILL/FIT/CROP/TILE).
    {
      nodeId: z.string().describe("The ID of the node to apply the image fill to"),
      imageData: z.string().max(7_000_000).describe("Base64-encoded image data (PNG, JPEG, GIF, or WebP). Max ~5MB after decode."),
      scaleMode: z.enum(["FILL", "FIT", "CROP", "TILE"]).optional().describe("How the image is scaled within the node (default: FILL)"),
    },
  • Registration call: registerModificationTools(server) is called from the central registerTools function, which wires the 'set_image' tool into the MCP server.
    registerModificationTools(server);
  • The registerModificationTools function declaration which internally uses server.tool() to register 'set_image' (line 662-697).
    export function registerModificationTools(server: McpServer): void {
  • Type definition: 'set_image' is listed as a valid FigmaCommand in the union type, ensuring type safety for command dispatch.
    | "set_image"

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.8.2

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations, description provides some behavioral context (supports formats, max size) but fails to disclose whether it replaces existing fills, creates new layers, or other side effects. Adequate but not comprehensive.

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, front-loaded with main action and followed by supporting details. No wasted words.

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

Completeness4/5

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

Covers essentials: action, input type, formats, size limit. Lacks return value info but tool is simple and has no output schema. Minor gap for completeness.

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 parameters are well-documented inside schema. Description reinforces constraints (max size, base64) but adds no new meaning beyond schema. Baseline 3.

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?

Description clearly states the tool sets an image fill on a node from base64 data, with specific verb and resource. It lists supported formats and size limit, distinguishing it from siblings like replace_image_fill.

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?

Implied usage as a general image fill setter, but no explicit guidance on when to use this vs alternatives like replace_image_fill. No when-not-to-use or prerequisites mentioned.

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

Deploy Server

Other Tools