Skip to main content
Glama
arinspunk

Claude Talk to Figma MCP

by arinspunk

set_paragraph_spacing

Adjust the vertical spacing between paragraphs in a Figma text node by specifying a pixel value. Solves inconsistent text layout by allowing precise control over paragraph separation.

Instructions

Set the paragraph spacing of a text node in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the text node to modify
paragraphSpacingYesParagraph spacing value in pixels

Implementation Reference

  • The tool handler that registers the 'set_paragraph_spacing' MCP tool. It defines the Zod schema for nodeId (string) and paragraphSpacing (number) inputs, sends the command to Figma via sendCommandToFigma, and returns a success/error message.
    // Set Paragraph Spacing Tool
    server.tool(
      "set_paragraph_spacing",
      "Set the paragraph spacing of a text node in Figma",
      {
        nodeId: z.string().describe("The ID of the text node to modify"),
        paragraphSpacing: z.coerce.number().describe("Paragraph spacing value in pixels"),
      },
      async ({ nodeId, paragraphSpacing }) => {
        try {
          const result = await sendCommandToFigma("set_paragraph_spacing", {
            nodeId,
            paragraphSpacing
          });
          const typedResult = result as { name: string, paragraphSpacing: number };
          return {
            content: [
              {
                type: "text",
                text: `Updated paragraph spacing of node "${typedResult.name}" to ${typedResult.paragraphSpacing}px`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting paragraph spacing: ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • The FigmaCommand type union member '"set_paragraph_spacing"' used for type-safe command dispatching.
    | "set_paragraph_spacing"
  • The tool is registered via server.tool('set_paragraph_spacing', ...) inside the registerTextTools function.
    // Set Paragraph Spacing Tool
    server.tool(
      "set_paragraph_spacing",
      "Set the paragraph spacing of a text node in Figma",
      {
        nodeId: z.string().describe("The ID of the text node to modify"),
        paragraphSpacing: z.coerce.number().describe("Paragraph spacing value in pixels"),
      },
      async ({ nodeId, paragraphSpacing }) => {
        try {
          const result = await sendCommandToFigma("set_paragraph_spacing", {
            nodeId,
            paragraphSpacing
          });
          const typedResult = result as { name: string, paragraphSpacing: number };
          return {
            content: [
              {
                type: "text",
                text: `Updated paragraph spacing of node "${typedResult.name}" to ${typedResult.paragraphSpacing}px`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting paragraph spacing: ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • The sendCommandToFigma utility function that sends the 'set_paragraph_spacing' command (and any command) over WebSocket to the Figma plugin server.
    export function sendCommandToFigma(
      command: FigmaCommand,
      params: unknown = {},
      timeoutMs: number = 300000
    ): Promise<unknown> {
      return new Promise((resolve, reject) => {
        // If not connected, try to connect first
        if (!ws || ws.readyState !== WebSocket.OPEN) {
          connectToFigma();
          reject(new Error("Not connected to Figma. Attempting to connect..."));
          return;
        }
    
        // Check if we need a channel for this command
        const requiresChannel = command !== "join";
        if (requiresChannel && !currentChannel) {
          reject(new Error("Must join a channel before sending commands"));
          return;
        }
    
        const id = uuidv4();
        const request = {
          id,
          type: command === "join" ? "join" : "message",
          ...(command === "join"
            ? { channel: (params as any).channel, sessionId: SESSION_ID }
            : { channel: currentChannel }),
          message: {
            id,
            command,
            params: {
              ...(params as any),
              commandId: id, // Include the command ID in params
            },
          },
        };
    
        // Set timeout for request
        const timeout = setTimeout(() => {
          if (pendingRequests.has(id)) {
            pendingRequests.delete(id);
            logger.error(`Request ${id} to Figma timed out after ${timeoutMs / 1000} seconds`);
            reject(new Error('Request to Figma timed out'));
          }
        }, timeoutMs);
    
        // Store the promise callbacks to resolve/reject later
        pendingRequests.set(id, {
          resolve,
          reject,
          timeout,
          lastActivity: Date.now()
        });
    
        // Send the request
        logger.info(`Sending command to Figma: ${command}`);
        logger.debug(`Request details: ${JSON.stringify(request)}`);
        ws.send(JSON.stringify(request));
      });
    }
Behavior2/5

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

No annotations are provided, so the description carries the burden of disclosing behaviors. It only states the action without mentioning side effects, error conditions, or requirements (e.g., node existence, valid range for spacing). Minimal transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no wasted words. Front-loaded with the action. However, it is almost too concise, missing optional context that could be added without harming conciseness.

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?

Given the tool's simplicity (2 params, no output schema), the description is minimally adequate. It does not explain return values or error handling, but for a basic setter this is acceptable. A bit more context would improve completeness.

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 descriptions for both parameters. The tool description adds no additional meaning beyond what the schema already provides. Baseline 3 is appropriate.

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 identifies the action ('Set'), the resource ('paragraph spacing of a text node'), and the domain ('Figma'). It distinguishes from sibling tools like set_font_size or set_line_height by specifying the exact property.

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?

No guidance on when to use this tool versus alternatives. Does not mention prerequisites (e.g., node must be a text node, must be loaded) or typical scenarios. With many sibling 'set_' tools, some usage context would help.

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/arinspunk/claude-talk-to-figma-mcp'

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