set_font_size
Adjust text font size in Figma by specifying the node ID and pixel value to modify design elements through the CC Fig MCP server.
Instructions
Set the font size of a text node in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the text node to modify | |
| fontSize | Yes | Font size in pixels |
Implementation Reference
- The handler function that implements the core logic of the set_font_size tool: sends the command to Figma via websocket, processes the response, and returns a success or error message.async ({ nodeId, fontSize }) => { try { const result = await sendCommandToFigma("set_font_size", { nodeId, fontSize }); const typedResult = result as { name: string, fontSize: number }; return { content: [ { type: "text", text: `Updated font size of node "${typedResult.name}" to ${typedResult.fontSize}px` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error setting font size: ${error instanceof Error ? error.message : String(error)}` } ] }; } }
- Zod schema defining the input parameters for the tool: nodeId (string) and fontSize (positive number).{ nodeId: z.string().describe("The ID of the text node to modify"), fontSize: z.number().positive().describe("Font size in pixels"), },
- src/talk_to_figma_mcp/tools/text-tools.ts:194-227 (registration)The server.tool() registration call that defines and registers the set_font_size MCP tool, including its name, description, input schema, and handler function.server.tool( "set_font_size", "Set the font size of a text node in Figma", { nodeId: z.string().describe("The ID of the text node to modify"), fontSize: z.number().positive().describe("Font size in pixels"), }, async ({ nodeId, fontSize }) => { try { const result = await sendCommandToFigma("set_font_size", { nodeId, fontSize }); const typedResult = result as { name: string, fontSize: number }; return { content: [ { type: "text", text: `Updated font size of node "${typedResult.name}" to ${typedResult.fontSize}px` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error setting font size: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- src/talk_to_figma_mcp/tools/index.ts:16-16 (registration)Higher-level registration call to registerTextTools(server), which includes the set_font_size tool among other text tools.registerTextTools(server);