Skip to content

feat: add set_fills tool for multi-fill stack support - #173

Open
Ananchai-m wants to merge 1 commit into
grab:mainfrom
Ananchai-m:feat/set-fills-multi-fill
Open

feat: add set_fills tool for multi-fill stack support#173
Ananchai-m wants to merge 1 commit into
grab:mainfrom
Ananchai-m:feat/set-fills-multi-fill

Conversation

@Ananchai-m

Copy link
Copy Markdown

Motivation

set_fill_color only accepts a single SOLID color and replaces the entire fills array — multi-fill stacks (base color + semi-transparent overlay, two stacked gradients, etc.) couldn't be set via MCP. This blocked testing converters / pipelines that handle multi-fill specifically.

Changes

Adds a set_fills tool accepting an array of paint specs:

set_fills({
  nodeId: "123:456",
  fills: [
    { type: "SOLID", color: { r: 0.85, g: 0.85, b: 0.85 }, opacity: 1 },
    { type: "SOLID", color: { r: 0, g: 0, b: 0 }, opacity: 0.5 },
  ],
})

Each entry takes type (SOLID / GRADIENT_LINEAR), color (or gradientStops for gradients), opacity, blendMode, and visible. Order is bottom-up: index 0 is the bottom-most layer, last entry renders on top — matches Figma's own fills array semantics.

Plugin handler builds the paint objects, validates required fields per type, and assigns to node.fills. Server exposes the tool with a zod schema mirroring the runtime validation.

Tests

Manually verified locally — calling set_fills on a Figma rectangle produces the expected stacked appearance, matches what the user would get from manually pressing + in Figma's Fill panel.

Files changed

  • src/talk_to_figma_mcp/server.ts — tool definition + zod schema + CommandParams entry
  • src/cursor_mcp_plugin/code.jssetFills() handler + dispatch case

set_fill_color only accepts a single SOLID color and replaces the
entire fills array — multi-fill stacks (base color + semi-transparent
overlay, two stacked gradients, etc.) couldn't be set via MCP.

Add set_fills tool accepting an array of paint specs. Each entry
takes type (SOLID / GRADIENT_LINEAR), color (or gradientStops for
gradients), opacity, blend mode, and visibility. Order is bottom-up:
index 0 is the bottom-most layer, last entry renders on top — matches
Figma's own fills array semantics.

Plugin handler builds the paint objects, validates required fields
per type, and assigns to node.fills. Server exposes the tool with a
zod schema mirroring the runtime validation.

Useful for testing converters / pipelines that handle multi-fill
specifically (e.g. nested-Frame native rendering instead of PNG
rasterisation).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant