Skip to main content
Glama
paragdesai1

Cursor Talk to Figma MCP

by paragdesai1

set_layout_mode

Configure auto-layout settings for frames in Figma designs, including orientation and wrap behavior, to organize design elements programmatically.

Instructions

Set the layout mode and wrap behavior of a frame in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the frame to modify
layoutModeYesLayout mode for the frame
layoutWrapNoWhether the auto-layout frame wraps its children

Implementation Reference

  • Core handler function in Figma plugin that sets the layoutMode and layoutWrap properties on the target frame/component node using Figma API.
    async function setLayoutMode(params) {
      const { nodeId, layoutMode = "NONE", layoutWrap = "NO_WRAP" } = 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 layoutMode
      if (
        node.type !== "FRAME" &&
        node.type !== "COMPONENT" &&
        node.type !== "COMPONENT_SET" &&
        node.type !== "INSTANCE"
      ) {
        throw new Error(`Node type ${node.type} does not support layoutMode`);
      }
    
      // Set layout mode
      node.layoutMode = layoutMode;
    
      // Set layoutWrap if applicable
      if (layoutMode !== "NONE") {
        node.layoutWrap = layoutWrap;
      }
    
      return {
        id: node.id,
        name: node.name,
        layoutMode: node.layoutMode,
        layoutWrap: node.layoutWrap,
      };
    }
  • MCP server tool registration including schema validation with Zod and proxy handler that forwards the command to Figma plugin via WebSocket.
    // Set Layout Mode Tool
    server.tool(
      "set_layout_mode",
      "Set the layout mode and wrap behavior of a frame in Figma",
      {
        nodeId: z.string().describe("The ID of the frame to modify"),
        layoutMode: z.enum(["NONE", "HORIZONTAL", "VERTICAL"]).describe("Layout mode for the frame"),
        layoutWrap: z.enum(["NO_WRAP", "WRAP"]).optional().describe("Whether the auto-layout frame wraps its children")
      },
      async ({ nodeId, layoutMode, layoutWrap }) => {
        try {
          const result = await sendCommandToFigma("set_layout_mode", {
            nodeId,
            layoutMode,
            layoutWrap: layoutWrap || "NO_WRAP"
          });
          const typedResult = result as { name: string };
          return {
            content: [
              {
                type: "text",
                text: `Set layout mode of frame "${typedResult.name}" to ${layoutMode}${layoutWrap ? ` with ${layoutWrap}` : ''}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting layout mode: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Input schema definition using Zod for validating nodeId (required), layoutMode (NONE/HORIZONTAL/VERTICAL), and optional layoutWrap (NO_WRAP/WRAP).
    {
      nodeId: z.string().describe("The ID of the frame to modify"),
      layoutMode: z.enum(["NONE", "HORIZONTAL", "VERTICAL"]).describe("Layout mode for the frame"),
      layoutWrap: z.enum(["NO_WRAP", "WRAP"]).optional().describe("Whether the auto-layout frame wraps its children")
    },
  • Dispatch case in Figma plugin's main handleCommand switch statement that routes to the setLayoutMode handler.
    case "set_layout_mode":
      return await setLayoutMode(params);
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. It states this is a mutation tool ('Set'), implying it modifies data, but doesn't specify whether changes are reversible, what permissions are required, or what happens on success/failure. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 with zero wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns, error conditions, or behavioral nuances like whether it affects child nodes. For a tool that modifies frame layout, more context is needed to use it effectively.

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%, so the schema already fully documents all three parameters (nodeId, layoutMode, layoutWrap) with descriptions and enums. The description adds no additional parameter semantics beyond what's in the schema, so it meets the baseline of 3 for high schema coverage.

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 verb ('Set') and resource ('layout mode and wrap behavior of a frame in Figma'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'set_layout_sizing' or 'set_axis_align', which also modify frame properties, so it doesn't fully distinguish from alternatives.

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 like 'set_layout_sizing' or 'set_axis_align', nor does it mention prerequisites such as needing a valid frame ID. It lacks explicit when/when-not instructions or named alternatives.

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