set_font_name
Assign a font family and style to a Figma text node. Specify the node ID and family name; optionally include a style such as Bold or Italic.
Instructions
Set the font name and style of a text node in Figma
Input 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
- Tool handler for 'set_font_name'. Defines the MCP tool with input schema (nodeId, family, optional style), calls sendCommandToFigma with the 'set_font_name' command, and returns success/error messages.
// Set Font Name Tool 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)}` } ] }; } } ); - src/talk_to_figma_mcp/tools/text-tools.ts:11-11 (registration)Registration function that registers the set_font_name tool (along with other text tools) on the MCP server via server.tool().
export function registerTextTools(server: McpServer): void { - Type definition for FigmaCommand union type, includes 'set_font_name' as a valid command value.
| "set_font_name" - Helper function that sends a command (including 'set_font_name') to Figma via WebSocket, used by the tool handler.
export function sendCommandToFigma( command: FigmaCommand, params: unknown = {}, timeoutMs: number = 300000 ): Promise<unknown> {