Skip to main content
Glama

set_axis_align

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

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

  • The handler function for the 'set_axis_align' tool. It sends the corresponding command to the Figma plugin via sendCommandToFigma with the nodeId, primaryAxisAlignItems, and counterAxisAlignItems parameters. It then formats a success or error response.
    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)}`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input parameters for the 'set_axis_align' tool: nodeId (required), primaryAxisAlignItems (optional enum), counterAxisAlignItems (optional enum).
    {
      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)")
    },
  • MCP tool registration using server.tool() for 'set_axis_align', including description, input schema, and handler function.
    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)}`,
              },
            ],
          };
        }
      }
    );

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv1.0.0
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / counterAxisAlignItems
      Added value: +{
      +  "description": "Counter axis alignment (MIN/MAX = top/bottom in horizontal, left/right in vertical)",
      +  "enum": [
      +    "MIN",
      +    "MAX",
      +    "CENTER",
      +    "BASELINE"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / nodeId
      Added value: +{
      +  "description": "The ID of the frame to modify",
      +  "type": "string"
      +}
    • addedInput schema / properties / primaryAxisAlignItems
      Added value: +{
      +  "description": "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.",
      +  "enum": [
      +    "MIN",
      +    "MAX",
      +    "CENTER",
      +    "SPACE_BETWEEN"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / required
      Added value: +[
      +  "nodeId"
      +]
  2. First observed

TDQS

A3.7/5.0
Behavior2/5

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

No annotations are present, so the description carries the full burden of behavioral disclosure. It only states the action without mentioning side effects, prerequisites (e.g., frame must already be auto-layout), error handling, or in-place mutation. This is a significant gap for a mutation tool.

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?

One sentence, 13 words, perfectly front-loaded with the action and target. Every word earns its place, with no wasted content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is adequate given the schema's thorough parameter documentation, but it omits important context like whether the frame must already be auto-layout, what happens if it isn't, and that there is no return value. No output schema or annotations increase the need for such context.

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 coverage is 100% with detailed descriptions for both enum parameters, including the SPACE_BETWEEN side effect. The description adds no additional parameter-specific semantics, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/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 the specific resources ('primary and counter axis alignment for an auto-layout frame'), making it straightforward to understand what the tool does. It is distinct from sibling tools like set_layout_mode or set_padding because it focuses specifically on alignment.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides a clear context by specifying it applies to 'an auto-layout frame', implying when the tool should be used. However, it does not explicitly mention alternatives or exclusions, so while the context is clear, there is no comparative guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.