Skip to main content
Glama
paragdesai1

Cursor Talk to Figma MCP

by paragdesai1

set_layout_sizing

Configure horizontal and vertical sizing modes for auto-layout frames in Figma designs. Choose between FIXED, HUG, or FILL modes to control how frames resize based on content.

Instructions

Set horizontal and vertical sizing modes for an auto-layout frame in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the frame to modify
layoutSizingHorizontalNoHorizontal sizing mode (HUG for frames/text only, FILL for auto-layout children only)
layoutSizingVerticalNoVertical sizing mode (HUG for frames/text only, FILL for auto-layout children only)

Implementation Reference

  • MCP tool registration for 'set_layout_sizing', including schema validation and forwarding handler to Figma plugin command.
    server.tool(
      "set_layout_sizing",
      "Set horizontal and vertical sizing modes for an auto-layout frame in Figma",
      {
        nodeId: z.string().describe("The ID of the frame to modify"),
        layoutSizingHorizontal: z
          .enum(["FIXED", "HUG", "FILL"])
          .optional()
          .describe("Horizontal sizing mode (HUG for frames/text only, FILL for auto-layout children only)"),
        layoutSizingVertical: z
          .enum(["FIXED", "HUG", "FILL"])
          .optional()
          .describe("Vertical sizing mode (HUG for frames/text only, FILL for auto-layout children only)")
      },
      async ({ nodeId, layoutSizingHorizontal, layoutSizingVertical }) => {
        try {
          const result = await sendCommandToFigma("set_layout_sizing", {
            nodeId,
            layoutSizingHorizontal,
            layoutSizingVertical
          });
          const typedResult = result as { name: string };
    
          // Create a message about which sizing modes were set
          const sizingMessages = [];
          if (layoutSizingHorizontal !== undefined) sizingMessages.push(`horizontal: ${layoutSizingHorizontal}`);
          if (layoutSizingVertical !== undefined) sizingMessages.push(`vertical: ${layoutSizingVertical}`);
    
          const sizingText = sizingMessages.length > 0
            ? `layout sizing (${sizingMessages.join(', ')})`
            : "layout sizing";
    
          return {
            content: [
              {
                type: "text",
                text: `Set ${sizingText} for frame "${typedResult.name}"`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting layout sizing: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Core implementation of set_layout_sizing Figma plugin command. Validates node type and auto-layout mode, then sets layoutSizingHorizontal and/or layoutSizingVertical properties with appropriate constraints and error handling.
    async function setLayoutSizing(params) {
      const { nodeId, layoutSizingHorizontal, layoutSizingVertical } = params || {};
    
      // Get the target node
      const node = await figma.getNodeByIdAsync(nodeId);
      if (!node) {
        throw new Error(`Node with ID ${nodeId} not found`);
      }
    
      // Check if node is a frame or component that supports layout sizing
      if (
        node.type !== "FRAME" &&
        node.type !== "COMPONENT" &&
        node.type !== "COMPONENT_SET" &&
        node.type !== "INSTANCE"
      ) {
        throw new Error(`Node type ${node.type} does not support layout sizing`);
      }
    
      // Check if the node has auto-layout enabled
      if (node.layoutMode === "NONE") {
        throw new Error(
          "Layout sizing can only be set on auto-layout frames (layoutMode must not be NONE)"
        );
      }
    
      // Validate and set layoutSizingHorizontal if provided
      if (layoutSizingHorizontal !== undefined) {
        if (!["FIXED", "HUG", "FILL"].includes(layoutSizingHorizontal)) {
          throw new Error(
            "Invalid layoutSizingHorizontal value. Must be one of: FIXED, HUG, FILL"
          );
        }
        // HUG is only valid on auto-layout frames and text nodes
        if (
          layoutSizingHorizontal === "HUG" &&
          !["FRAME", "TEXT"].includes(node.type)
        ) {
          throw new Error(
            "HUG sizing is only valid on auto-layout frames and text nodes"
          );
        }
        // FILL is only valid on auto-layout children
        if (
          layoutSizingHorizontal === "FILL" &&
          (!node.parent || node.parent.layoutMode === "NONE")
        ) {
          throw new Error("FILL sizing is only valid on auto-layout children");
        }
        node.layoutSizingHorizontal = layoutSizingHorizontal;
      }
    
      // Validate and set layoutSizingVertical if provided
      if (layoutSizingVertical !== undefined) {
        if (!["FIXED", "HUG", "FILL"].includes(layoutSizingVertical)) {
          throw new Error(
            "Invalid layoutSizingVertical value. Must be one of: FIXED, HUG, FILL"
          );
        }
        // HUG is only valid on auto-layout frames and text nodes
        if (
          layoutSizingVertical === "HUG" &&
          !["FRAME", "TEXT"].includes(node.type)
        ) {
          throw new Error(
            "HUG sizing is only valid on auto-layout frames and text nodes"
          );
        }
        // FILL is only valid on auto-layout children
        if (
          layoutSizingVertical === "FILL" &&
          (!node.parent || node.parent.layoutMode === "NONE")
        ) {
          throw new Error("FILL sizing is only valid on auto-layout children");
        }
        node.layoutSizingVertical = layoutSizingVertical;
      }
    
      return {
        id: node.id,
        name: node.name,
        layoutSizingHorizontal: node.layoutSizingHorizontal,
        layoutSizingVertical: node.layoutSizingVertical,
        layoutMode: node.layoutMode,
      };
    }
  • Dispatches Figma command 'set_layout_sizing' to the setLayoutSizing handler function.
    case "set_layout_sizing":
      return await setLayoutSizing(params);
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. It states this is a modification tool ('Set'), implying mutation, but doesn't address permissions needed, whether changes are reversible, error conditions, or what happens to existing sizing settings. The description provides minimal behavioral context beyond the basic action.

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 gets straight to the point with zero wasted words. It's appropriately sized for a tool with 3 parameters and good schema documentation.

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 no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, or important behavioral details like whether the operation is idempotent or requires specific permissions. The description leaves significant gaps given the tool's complexity and lack of structured metadata.

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 all parameters well-documented in the schema itself. The description doesn't add any parameter-specific information beyond what's already in the schema descriptions, so it meets the baseline expectation when schema coverage is high.

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 ('Set') and target ('horizontal and vertical sizing modes for an auto-layout frame in Figma'), providing specific verb+resource. However, it doesn't explicitly distinguish this tool from similar sibling tools like 'set_layout_mode' or 'set_axis_align', which also modify layout properties.

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?

No guidance is provided about when to use this tool versus alternatives. While the description specifies it's for 'auto-layout frame', it doesn't mention prerequisites, constraints, or when other layout-related tools might be more appropriate.

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/paragdesai1/parag-Figma-MCP'

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