FigmaMCP

Figma MCP auto layout

FigmaMCP lets Claude Code or Codex turn auto layout on for a frame and set direction, wrapping, padding, spacing, alignment and sizing, all through one tool: node_set_auto_layout. Each call changes one frame, and the frame’s name must match. Ask for a picture afterwards, so the agent can check its own work.

Examples

Auto layout requests
You askResult
“Stack these items vertically with 12px gap”Vertical auto layout, spacing 12
“Add 24px padding all round”Padding 24 on all sides
“Centre the content”Alignment set to centre

Parameters of node_set_auto_layout

FigmaMCP’s node_set_auto_layout is one setter. You send nodeId, the frame’s exact nodeName, and any of the fields below. Fields you leave out stay as they are.

node_set_auto_layout fields
FieldValuesNote
layoutModeNONE, HORIZONTAL, VERTICALNONE turns auto layout off.
layoutWrapNO_WRAP, WRAPWrapping rows or columns.
paddingTop, paddingRight, paddingBottom, paddingLeftNumbersSet each side on its own.
itemSpacingNumberIgnored when the primary axis uses SPACE_BETWEEN.
counterAxisSpacingNumberWorks only when layoutWrap is WRAP.
primaryAxisAlignItemsMIN, MAX, CENTER, SPACE_BETWEENAlong the layout direction.
counterAxisAlignItemsMIN, MAX, CENTER, BASELINEAcross the layout direction.
layoutSizingHorizontal, layoutSizingVerticalFIXED, HUG, FILLHUG suits frames and text. FILL suits children of an auto layout frame.

Turn a stack of frames into auto layout

  1. Read the page with page_info, then the frame with node_info. Copy its exact name.
  2. Call node_set_auto_layout with the direction, spacing and padding you want.
  3. Export the frame with node_export_visual and look at the picture.
  4. Repeat for the next frame.

The tool takes one frame per call. A whole page therefore means many calls, and each call checks its own name. There is no batch that rolls back. If you ask for a page, ask the agent to do one section first and show you the picture.

Auto layout and variables

FigmaMCP can bind padding and spacing to variables with node_bind_variable, for fields such as paddingLeft and itemSpacing. The frame must have auto layout on first. If it does not, the bind fails with a message that auto layout is off. Run node_set_auto_layout with a layoutMode, then bind.

When a call is refused

Auto layout errors
Error or messageMeaningWhat to do
NAME_MISMATCHThe name you sent is not the frame’s current name.Read the frame again with node_info, then retry.
READ_ONLY_MODEThe AI can edit this file switch is off.Turn it on in the plugin.
OUTSIDE_SCOPEThe frame is outside the editable scope.Pick a frame inside the scope.
Operation Denied: lockedThe frame or one of its ancestors is locked.Unlock it in Figma.

Ask for a picture after the change: see Figma MCP export image.

Download for Mac Version 0.1.20 macOS 14+ · Intel & Apple Silicon · ~155 MB

Related: All tools · Write tools · Export

Questions

Can it convert a whole page to auto layout?
It can do it frame by frame. The tool changes one frame per call, so a page means many calls. Start with one section and check the picture.
Can it set different padding on each side?
Yes. node_set_auto_layout has separate paddingTop, paddingRight, paddingBottom and paddingLeft fields.
Why was my spacing ignored?
Two cases. itemSpacing is ignored when the primary axis alignment is SPACE_BETWEEN, because the children are spread evenly. counterAxisSpacing works only when layoutWrap is WRAP.
Can it bind spacing to a variable?
Yes, with node_bind_variable. Turn auto layout on first with node_set_auto_layout, or the bind is refused.

Last updated: