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)}`
              }
            ]
          };
        }
      }
    );
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Configure' implies a mutation operation, but the description doesn't specify whether this requires specific permissions, whether changes are destructive or reversible, what happens to existing auto layout settings not mentioned, or what the response looks like. For a mutation tool with 11 parameters and zero annotation coverage, this is a significant gap in behavioral context.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with every word earning its place. This represents ideal conciseness for a tool description.

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 mutation tool with 11 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what happens after configuration, what values are returned (if any), error conditions, or behavioral implications. The agent would need to guess about the tool's effects and response format based solely on the parameter schema.

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%, with each parameter clearly documented in the schema itself. The description doesn't add any additional parameter semantics beyond what's already in the schema descriptions. According to the rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description.

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 resource ('auto layout properties for a node in Figma'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'set_corner_radius' or 'set_effects' beyond the specific property being configured, which prevents a perfect score.

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. It doesn't mention prerequisites (e.g., needing a valid node ID), when auto layout is applicable, or how it relates to sibling tools like 'resize_node' or 'group_nodes' that might affect layout. This leaves the agent without contextual usage information.

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/agenisea/cc-fig-mcp'

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