Skip to main content
Glama
paragdesai1

Cursor Talk to Figma MCP

by paragdesai1

set_axis_align

Adjust alignment for auto-layout frames in Figma by setting primary and counter axis positions to control element arrangement within designs.

Instructions

Set primary and counter axis alignment for an auto-layout frame in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the frame to modify
primaryAxisAlignItemsNoPrimary axis alignment (MIN/MAX = left/right in horizontal, top/bottom in vertical). Note: When set to SPACE_BETWEEN, itemSpacing will be ignored as children will be evenly spaced.
counterAxisAlignItemsNoCounter axis alignment (MIN/MAX = top/bottom in horizontal, left/right in vertical)

Implementation Reference

  • Registration of the 'set_axis_align' MCP tool, including input schema (Zod validation) and handler function that forwards the command to the Figma plugin via WebSocket.
    server.tool(
      "set_axis_align",
      "Set primary and counter axis alignment for an auto-layout frame in Figma",
      {
        nodeId: z.string().describe("The ID of the frame to modify"),
        primaryAxisAlignItems: z
          .enum(["MIN", "MAX", "CENTER", "SPACE_BETWEEN"])
          .optional()
          .describe("Primary axis alignment (MIN/MAX = left/right in horizontal, top/bottom in vertical). Note: When set to SPACE_BETWEEN, itemSpacing will be ignored as children will be evenly spaced."),
        counterAxisAlignItems: z
          .enum(["MIN", "MAX", "CENTER", "BASELINE"])
          .optional()
          .describe("Counter axis alignment (MIN/MAX = top/bottom in horizontal, left/right in vertical)")
      },
      async ({ nodeId, primaryAxisAlignItems, counterAxisAlignItems }) => {
        try {
          const result = await sendCommandToFigma("set_axis_align", {
            nodeId,
            primaryAxisAlignItems,
            counterAxisAlignItems
          });
          const typedResult = result as { name: string };
    
          // Create a message about which alignments were set
          const alignMessages = [];
          if (primaryAxisAlignItems !== undefined) alignMessages.push(`primary: ${primaryAxisAlignItems}`);
          if (counterAxisAlignItems !== undefined) alignMessages.push(`counter: ${counterAxisAlignItems}`);
    
          const alignText = alignMessages.length > 0
            ? `axis alignment (${alignMessages.join(', ')})`
            : "axis alignment";
    
          return {
            content: [
              {
                type: "text",
                text: `Set ${alignText} for frame "${typedResult.name}"`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting axis alignment: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Input schema for set_axis_align tool using Zod for validation of nodeId, primaryAxisAlignItems, and counterAxisAlignItems.
      nodeId: z.string().describe("The ID of the frame to modify"),
      primaryAxisAlignItems: z
        .enum(["MIN", "MAX", "CENTER", "SPACE_BETWEEN"])
        .optional()
        .describe("Primary axis alignment (MIN/MAX = left/right in horizontal, top/bottom in vertical). Note: When set to SPACE_BETWEEN, itemSpacing will be ignored as children will be evenly spaced."),
      counterAxisAlignItems: z
        .enum(["MIN", "MAX", "CENTER", "BASELINE"])
        .optional()
        .describe("Counter axis alignment (MIN/MAX = top/bottom in horizontal, left/right in vertical)")
    },
  • Handler implementation that sends the set_axis_align command to Figma WebSocket server, processes the response, and returns formatted success/error text content.
    async ({ nodeId, primaryAxisAlignItems, counterAxisAlignItems }) => {
      try {
        const result = await sendCommandToFigma("set_axis_align", {
          nodeId,
          primaryAxisAlignItems,
          counterAxisAlignItems
        });
        const typedResult = result as { name: string };
    
        // Create a message about which alignments were set
        const alignMessages = [];
        if (primaryAxisAlignItems !== undefined) alignMessages.push(`primary: ${primaryAxisAlignItems}`);
        if (counterAxisAlignItems !== undefined) alignMessages.push(`counter: ${counterAxisAlignItems}`);
    
        const alignText = alignMessages.length > 0
          ? `axis alignment (${alignMessages.join(', ')})`
          : "axis alignment";
    
        return {
          content: [
            {
              type: "text",
              text: `Set ${alignText} for frame "${typedResult.name}"`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error setting axis alignment: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }

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