Skip to main content
Glama

set_item_spacing

Adjust spacing between elements in auto-layout frames to control visual hierarchy and alignment in Figma designs.

Instructions

Set distance between children in an auto-layout frame

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the frame to modify
itemSpacingYesDistance between children. Note: This value will be ignored if primaryAxisAlignItems is set to SPACE_BETWEEN.

Implementation Reference

  • Registration of the MCP tool 'set_item_spacing'. Includes the tool name, description, input schema (nodeId: string, itemSpacing: number), and the handler function that sends a 'set_item_spacing' command to the Figma plugin via WebSocket and formats the response.
    // Set Item Spacing Tool
    server.tool(
      "set_item_spacing",
      "Set distance between children in an auto-layout frame",
      {
        nodeId: z.string().describe("The ID of the frame to modify"),
        itemSpacing: z.number().describe("Distance between children. Note: This value will be ignored if primaryAxisAlignItems is set to SPACE_BETWEEN.")
      },
      async ({ nodeId, itemSpacing }) => {
        try {
          const result = await sendCommandToFigma("set_item_spacing", {
            nodeId,
            itemSpacing
          });
          const typedResult = result as { name: string };
    
          return {
            content: [
              {
                type: "text",
                text: `Set item spacing to ${itemSpacing} for frame "${typedResult.name}"`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting item spacing: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Input schema for the 'set_item_spacing' tool using Zod validation: requires nodeId (string) and itemSpacing (number).
      nodeId: z.string().describe("The ID of the frame to modify"),
      itemSpacing: z.number().describe("Distance between children. Note: This value will be ignored if primaryAxisAlignItems is set to SPACE_BETWEEN.")
    },
  • Handler function for the 'set_item_spacing' tool. Proxies the parameters to the Figma plugin using sendCommandToFigma('set_item_spacing'), handles the result by extracting the frame name, and returns a formatted text response or error message.
    async ({ nodeId, itemSpacing }) => {
      try {
        const result = await sendCommandToFigma("set_item_spacing", {
          nodeId,
          itemSpacing
        });
        const typedResult = result as { name: string };
    
        return {
          content: [
            {
              type: "text",
              text: `Set item spacing to ${itemSpacing} for frame "${typedResult.name}"`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error setting item spacing: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
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 the tool modifies a frame but doesn't specify whether this is a destructive mutation, permission requirements, error conditions, or what happens when applied incorrectly (e.g., to non-auto-layout frames). The description is minimal and lacks critical behavioral context.

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 every word earn its place.

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 incomplete. It doesn't address what the tool returns, error handling, side effects, or how it interacts with other layout properties. Given the complexity of modifying auto-layout frames, more context is needed for safe and effective use.

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%, providing complete parameter documentation. The description doesn't add any meaningful parameter semantics beyond what's in the schema (e.g., it doesn't explain units for 'itemSpacing' or valid ranges). Baseline 3 is appropriate when the schema does all the work.

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 distance') and target resource ('children in an auto-layout frame'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'set_layout_mode' or 'set_layout_sizing' that also affect layout properties, missing full sibling differentiation.

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. It doesn't mention prerequisites (e.g., requiring an auto-layout frame), exclusions, or compare to related tools like 'set_padding' or 'set_layout_sizing', leaving usage context entirely implicit.

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/pipethedev/Talk-to-Figma-MCP'

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