Skip to main content
Glama

set_auto_layout

Configure auto layout properties for Figma nodes to control layout direction, spacing, alignment, and padding for organized design elements.

Instructions

Configure auto layout properties for a node in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the node to configure auto layout
layoutModeYesLayout direction
paddingTopNoTop padding in pixels
paddingBottomNoBottom padding in pixels
paddingLeftNoLeft padding in pixels
paddingRightNoRight padding in pixels
itemSpacingNoSpacing between items in pixels
primaryAxisAlignItemsNoAlignment along primary axis
counterAxisAlignItemsNoAlignment along counter axis
layoutWrapNoWhether items wrap to new lines
strokesIncludedInLayoutNoWhether strokes are included in layout calculations

Implementation Reference

  • The handler function that implements the core logic of the 'set_auto_layout' tool by forwarding parameters to the Figma WebSocket command.
    async ({ nodeId, layoutMode, paddingTop, paddingBottom, paddingLeft, paddingRight, 
             itemSpacing, primaryAxisAlignItems, counterAxisAlignItems, layoutWrap, strokesIncludedInLayout }) => {
      try {
        const result = await sendCommandToFigma("set_auto_layout", { 
          nodeId, 
          layoutMode, 
          paddingTop, 
          paddingBottom, 
          paddingLeft, 
          paddingRight, 
          itemSpacing, 
          primaryAxisAlignItems, 
          counterAxisAlignItems, 
          layoutWrap, 
          strokesIncludedInLayout 
        });
        
        const typedResult = result as { name: string };
        return {
          content: [
            {
              type: "text",
              text: `Applied auto layout to node "${typedResult.name}" with mode: ${layoutMode}`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error setting auto layout: ${error instanceof Error ? error.message : String(error)}`
            }
          ]
        };
      }
    }
  • Zod schema defining the input parameters and validation for the 'set_auto_layout' tool.
    {
      nodeId: z.string().describe("The ID of the node to configure auto layout"),
      layoutMode: z.enum(["HORIZONTAL", "VERTICAL", "NONE"]).describe("Layout direction"),
      paddingTop: z.number().optional().describe("Top padding in pixels"),
      paddingBottom: z.number().optional().describe("Bottom padding in pixels"),
      paddingLeft: z.number().optional().describe("Left padding in pixels"),
      paddingRight: z.number().optional().describe("Right padding in pixels"),
      itemSpacing: z.number().optional().describe("Spacing between items in pixels"),
      primaryAxisAlignItems: z.enum(["MIN", "CENTER", "MAX", "SPACE_BETWEEN"]).optional().describe("Alignment along primary axis"),
      counterAxisAlignItems: z.enum(["MIN", "CENTER", "MAX"]).optional().describe("Alignment along counter axis"),
      layoutWrap: z.enum(["WRAP", "NO_WRAP"]).optional().describe("Whether items wrap to new lines"),
      strokesIncludedInLayout: z.boolean().optional().describe("Whether strokes are included in layout calculations")
    },
  • Registration of the 'set_auto_layout' MCP tool on the server within the registerModificationTools function.
    server.tool(
      "set_auto_layout",
      "Configure auto layout properties for a node in Figma",
      {
        nodeId: z.string().describe("The ID of the node to configure auto layout"),
        layoutMode: z.enum(["HORIZONTAL", "VERTICAL", "NONE"]).describe("Layout direction"),
        paddingTop: z.number().optional().describe("Top padding in pixels"),
        paddingBottom: z.number().optional().describe("Bottom padding in pixels"),
        paddingLeft: z.number().optional().describe("Left padding in pixels"),
        paddingRight: z.number().optional().describe("Right padding in pixels"),
        itemSpacing: z.number().optional().describe("Spacing between items in pixels"),
        primaryAxisAlignItems: z.enum(["MIN", "CENTER", "MAX", "SPACE_BETWEEN"]).optional().describe("Alignment along primary axis"),
        counterAxisAlignItems: z.enum(["MIN", "CENTER", "MAX"]).optional().describe("Alignment along counter axis"),
        layoutWrap: z.enum(["WRAP", "NO_WRAP"]).optional().describe("Whether items wrap to new lines"),
        strokesIncludedInLayout: z.boolean().optional().describe("Whether strokes are included in layout calculations")
      },
      async ({ nodeId, layoutMode, paddingTop, paddingBottom, paddingLeft, paddingRight, 
               itemSpacing, primaryAxisAlignItems, counterAxisAlignItems, layoutWrap, strokesIncludedInLayout }) => {
        try {
          const result = await sendCommandToFigma("set_auto_layout", { 
            nodeId, 
            layoutMode, 
            paddingTop, 
            paddingBottom, 
            paddingLeft, 
            paddingRight, 
            itemSpacing, 
            primaryAxisAlignItems, 
            counterAxisAlignItems, 
            layoutWrap, 
            strokesIncludedInLayout 
          });
          
          const typedResult = result as { name: string };
          return {
            content: [
              {
                type: "text",
                text: `Applied auto layout to node "${typedResult.name}" with mode: ${layoutMode}`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting auto layout: ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Configure' implies a mutation operation, but the description doesn't specify whether this overwrites existing settings, requires specific permissions, or has side effects. For a tool with 11 parameters that modifies node properties, this minimal description leaves critical behavioral aspects undocumented.

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 a single, efficient sentence that states exactly what the tool does without any wasted words. It's appropriately sized for a configuration tool and gets straight to the point with clear subject-verb-object structure.

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?

For a complex mutation tool with 11 parameters and no annotations or output schema, the description is insufficiently complete. It doesn't explain what happens when properties are configured, whether all parameters must be specified, what defaults apply, or what the tool returns. The combination of mutation behavior, parameter complexity, and lack of structured metadata requires more descriptive context than provided.

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?

The description mentions 'auto layout properties' which aligns with the parameter names in the schema, but adds no additional semantic context beyond what the 100% schema coverage already provides. The schema descriptions thoroughly document each parameter's purpose, enum values, and units, so the description doesn't compensate but doesn't need to given the comprehensive schema.

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 action ('configure') and target ('auto layout properties for a node in Figma'), making the purpose immediately understandable. However, it doesn't differentiate this tool from similar configuration tools like 'set_corner_radius' or 'set_effects' beyond the specific property being configured.

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. There's no mention of prerequisites (e.g., the node must exist), when this operation is appropriate, or what happens if auto layout is already configured. With many sibling tools for node modification, this lack of contextual guidance is a significant gap.

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