set_paragraph_spacing
Adjust paragraph spacing in Figma text nodes to control vertical spacing between paragraphs for improved readability and layout design.
Instructions
Set the paragraph spacing of a text node in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the text node to modify | |
| paragraphSpacing | Yes | Paragraph spacing value in pixels |
Implementation Reference
- The handler function that executes the set_paragraph_spacing tool logic by sending the command to Figma via websocket and returning formatted success or error response.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)}` } ] }; } } );
- Input schema using Zod for validating nodeId (string) and paragraphSpacing (number) parameters.{ nodeId: z.string().describe("The ID of the text node to modify"), paragraphSpacing: z.number().describe("Paragraph spacing value in pixels"), },
- src/talk_to_figma_mcp/tools/text-tools.ts:342-375 (registration)Registers the set_paragraph_spacing tool on the MCP server with description, input schema, and handler function.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.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)}` } ] }; } } );
- src/talk_to_figma_mcp/tools/index.ts:16-16 (registration)Calls registerTextTools which includes the registration of set_paragraph_spacing among other text tools.registerTextTools(server);
- src/talk_to_figma_mcp/server.ts:34-34 (registration)Top-level call to registerTools which triggers registration of all tools including set_paragraph_spacing.registerTools(server);