set_font_name
Change the font family and style for text elements in Figma designs by specifying the node ID and desired typography.
Instructions
Set the font name and style of a text node in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the text node to modify | |
| family | Yes | Font family name | |
| style | No | Font style (e.g., 'Regular', 'Bold', 'Italic') |
Implementation Reference
- src/talk_to_figma_mcp/tools/text-tools.ts:156-191 (registration)Registers the 'set_font_name' MCP tool on the server, defining its description, input schema (nodeId, family, style), and handler function that forwards the command to Figma via websocket and formats the response.server.tool( "set_font_name", "Set the font name and style of a text node in Figma", { nodeId: z.string().describe("The ID of the text node to modify"), family: z.string().describe("Font family name"), style: z.string().optional().describe("Font style (e.g., 'Regular', 'Bold', 'Italic')"), }, async ({ nodeId, family, style }) => { try { const result = await sendCommandToFigma("set_font_name", { nodeId, family, style }); const typedResult = result as { name: string, fontName: { family: string, style: string } }; return { content: [ { type: "text", text: `Updated font of node "${typedResult.name}" to ${typedResult.fontName.family} ${typedResult.fontName.style}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error setting font name: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- The core handler logic for the 'set_font_name' tool: sends the command to Figma, type-casts the result, and returns a formatted text response or error.async ({ nodeId, family, style }) => { try { const result = await sendCommandToFigma("set_font_name", { nodeId, family, style }); const typedResult = result as { name: string, fontName: { family: string, style: string } }; return { content: [ { type: "text", text: `Updated font of node "${typedResult.name}" to ${typedResult.fontName.family} ${typedResult.fontName.style}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error setting font name: ${error instanceof Error ? error.message : String(error)}` } ] }; } }
- Zod schema for input parameters: nodeId (string), family (string), style (optional string).{ nodeId: z.string().describe("The ID of the text node to modify"), family: z.string().describe("Font family name"), style: z.string().optional().describe("Font style (e.g., 'Regular', 'Bold', 'Italic')"), },
- Type definition including 'set_font_name' in the FigmaCommand union type for internal command validation.| "set_font_name"
- src/talk_to_figma_mcp/tools/index.ts:16-16 (registration)Calls registerTextTools which includes registration of 'set_font_name' tool.registerTextTools(server);