Skip to main content
Glama
arinspunk

Claude Talk to Figma MCP

by arinspunk

load_font_async

Load fonts asynchronously in Figma to ensure text elements display correctly with specified font families and styles during design workflows.

Instructions

Load a font asynchronously in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
familyYesFont family name
styleNoFont style (e.g., 'Regular', 'Bold', 'Italic')

Implementation Reference

  • Registration of the 'load_font_async' MCP tool including name, description, input schema, and handler function.
    server.tool(
      "load_font_async",
      "Load a font asynchronously in Figma",
      {
        family: z.string().describe("Font family name"),
        style: z.string().optional().describe("Font style (e.g., 'Regular', 'Bold', 'Italic')"),
      },
      async ({ family, style }) => {
        try {
          const result = await sendCommandToFigma("load_font_async", {
            family,
            style: style || "Regular"
          });
          const typedResult = result as { success: boolean, family: string, style: string, message: string };
          return {
            content: [
              {
                type: "text",
                text: typedResult.message || `Loaded font ${family} ${style || "Regular"}`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error loading font: ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • The handler function that executes the load_font_async tool logic by sending a command to the Figma plugin via websocket and formatting the response.
    async ({ family, style }) => {
      try {
        const result = await sendCommandToFigma("load_font_async", {
          family,
          style: style || "Regular"
        });
        const typedResult = result as { success: boolean, family: string, style: string, message: string };
        return {
          content: [
            {
              type: "text",
              text: typedResult.message || `Loaded font ${family} ${style || "Regular"}`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error loading font: ${error instanceof Error ? error.message : String(error)}`
            }
          ]
        };
      }
  • Input schema validation for the load_font_async tool using Zod, defining 'family' (required string) and 'style' (optional string).
    {
      family: z.string().describe("Font family name"),
      style: z.string().optional().describe("Font style (e.g., 'Regular', 'Bold', 'Italic')"),
    },
  • Higher-level registration that calls registerTextTools(server), which includes load_font_async.
    export function registerTools(server: McpServer): void {
      // Register all tool categories
      registerDocumentTools(server);
      registerCreationTools(server);
      registerModificationTools(server);
      registerTextTools(server);
      registerComponentTools(server);
    }
  • Top-level MCP server setup that registers all tools, indirectly registering load_font_async.
    registerTools(server);

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