Skip to main content
Glama

set_layout_mode

Adjust the layout mode and wrap behavior of frames in Figma to streamline design structure. Tailor layouts programmatically for precise modifications in automated workflows.

Instructions

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

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {}, "type": "object" }

Implementation Reference

  • Registration of the 'set_layout_mode' MCP tool, including schema validation with Zod and the handler function that sends the command to the Figma plugin via WebSocket.
    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)}`, }, ], }; } } );
  • Handler function for the 'set_layout_mode' tool that proxies the layout mode setting to the underlying Figma plugin.
    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 for the 'set_layout_mode' tool using Zod for validation of nodeId, layoutMode, and optional layoutWrap.
    { 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") },

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/andreycretsu/cursor-talk-to-figma-mcp-main'

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