Skip to main content
Glama
paragdesai1

Cursor Talk to Figma MCP

by paragdesai1

create_text

Add text elements to Figma designs by specifying position, content, and styling properties like font size, weight, and color.

Instructions

Create a new text element in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYesX position
yYesY position
textYesText content
fontSizeNoFont size (default: 14)
fontWeightNoFont weight (e.g., 400 for Regular, 700 for Bold)
fontColorNoFont color in RGBA format
nameNoSemantic layer name for the text node
parentIdNoOptional parent node ID to append the text to

Implementation Reference

  • The core handler function that creates a Figma text node, loads Inter font based on weight, sets text content using setCharacters helper, applies color fill, positions it, and appends to specified parent or current page. Returns detailed node info.
    async function createText(params) {
      const {
        x = 0,
        y = 0,
        text = "Text",
        fontSize = 14,
        fontWeight = 400,
        fontColor = { r: 0, g: 0, b: 0, a: 1 }, // Default to black
        name = "",
        parentId,
      } = params || {};
    
      // Map common font weights to Figma font styles
      const getFontStyle = (weight) => {
        switch (weight) {
          case 100:
            return "Thin";
          case 200:
            return "Extra Light";
          case 300:
            return "Light";
          case 400:
            return "Regular";
          case 500:
            return "Medium";
          case 600:
            return "Semi Bold";
          case 700:
            return "Bold";
          case 800:
            return "Extra Bold";
          case 900:
            return "Black";
          default:
            return "Regular";
        }
      };
    
      const textNode = figma.createText();
      textNode.x = x;
      textNode.y = y;
      textNode.name = name || text;
      try {
        await figma.loadFontAsync({
          family: "Inter",
          style: getFontStyle(fontWeight),
        });
        textNode.fontName = { family: "Inter", style: getFontStyle(fontWeight) };
        textNode.fontSize = parseInt(fontSize);
      } catch (error) {
        console.error("Error setting font size", error);
      }
      setCharacters(textNode, text);
    
      // Set text color
      const paintStyle = {
        type: "SOLID",
        color: {
          r: parseFloat(fontColor.r) || 0,
          g: parseFloat(fontColor.g) || 0,
          b: parseFloat(fontColor.b) || 0,
        },
        opacity: parseFloat(fontColor.a) || 1,
      };
      textNode.fills = [paintStyle];
    
      // If parentId is provided, append to that node, otherwise append to current page
      if (parentId) {
        const parentNode = await figma.getNodeByIdAsync(parentId);
        if (!parentNode) {
          throw new Error(`Parent node not found with ID: ${parentId}`);
        }
        if (!("appendChild" in parentNode)) {
          throw new Error(`Parent node does not support children: ${parentId}`);
        }
        parentNode.appendChild(textNode);
      } else {
        figma.currentPage.appendChild(textNode);
      }
    
      return {
        id: textNode.id,
        name: textNode.name,
        x: textNode.x,
        y: textNode.y,
        width: textNode.width,
        height: textNode.height,
        characters: textNode.characters,
        fontSize: textNode.fontSize,
        fontWeight: fontWeight,
        fontColor: fontColor,
        fontName: textNode.fontName,
        fills: textNode.fills,
        parentId: textNode.parent ? textNode.parent.id : undefined,
      };
    }
  • MCP tool registration for 'create_text'. Defines input schema with zod validation for parameters like position, text, font properties, and proxies the command to the Figma plugin via WebSocket, returning success message with created node ID.
    server.tool(
      "create_text",
      "Create a new text element in Figma",
      {
        x: z.number().describe("X position"),
        y: z.number().describe("Y position"),
        text: z.string().describe("Text content"),
        fontSize: z.number().optional().describe("Font size (default: 14)"),
        fontWeight: z
          .number()
          .optional()
          .describe("Font weight (e.g., 400 for Regular, 700 for Bold)"),
        fontColor: z
          .object({
            r: z.number().min(0).max(1).describe("Red component (0-1)"),
            g: z.number().min(0).max(1).describe("Green component (0-1)"),
            b: z.number().min(0).max(1).describe("Blue component (0-1)"),
            a: z
              .number()
              .min(0)
              .max(1)
              .optional()
              .describe("Alpha component (0-1)"),
          })
          .optional()
          .describe("Font color in RGBA format"),
        name: z
          .string()
          .optional()
          .describe("Semantic layer name for the text node"),
        parentId: z
          .string()
          .optional()
          .describe("Optional parent node ID to append the text to"),
      },
      async ({ x, y, text, fontSize, fontWeight, fontColor, name, parentId }) => {
        try {
          const result = await sendCommandToFigma("create_text", {
            x,
            y,
            text,
            fontSize: fontSize || 14,
            fontWeight: fontWeight || 400,
            fontColor: fontColor || { r: 0, g: 0, b: 0, a: 1 },
            name: name || "Text",
            parentId,
          });
          const typedResult = result as { name: string; id: string };
          return {
            content: [
              {
                type: "text",
                text: `Created text "${typedResult.name}" with ID: ${typedResult.id}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error creating text: ${error instanceof Error ? error.message : String(error)
                  }`,
              },
            ],
          };
        }
      }
    );
  • Zod schema defining input parameters for the create_text tool: position (x,y), text content, optional fontSize, fontWeight, fontColor (RGBA), name, and parentId.
    {
      x: z.number().describe("X position"),
      y: z.number().describe("Y position"),
      text: z.string().describe("Text content"),
      fontSize: z.number().optional().describe("Font size (default: 14)"),
      fontWeight: z
        .number()
        .optional()
        .describe("Font weight (e.g., 400 for Regular, 700 for Bold)"),
      fontColor: z
        .object({
          r: z.number().min(0).max(1).describe("Red component (0-1)"),
          g: z.number().min(0).max(1).describe("Green component (0-1)"),
          b: z.number().min(0).max(1).describe("Blue component (0-1)"),
          a: z
            .number()
            .min(0)
            .max(1)
            .optional()
            .describe("Alpha component (0-1)"),
        })
        .optional()
        .describe("Font color in RGBA format"),
      name: z
        .string()
        .optional()
        .describe("Semantic layer name for the text node"),
      parentId: z
        .string()
        .optional()
        .describe("Optional parent node ID to append the text to"),
    },
  • Dispatch case in handleCommand switch statement that routes 'create_text' commands to the createText handler function.
          return await createText(params);
        case "set_fill_color":
          return await setFillColor(params);
        case "set_stroke_color":
          return await setStrokeColor(params);
        case "move_node":
          return await moveNode(params);
        case "resize_node":
          return await resizeNode(params);
        case "delete_node":
          return await deleteNode(params);
        case "delete_multiple_nodes":
          return await deleteMultipleNodes(params);
        case "get_styles":
          return await getStyles();
        case "get_local_components":
          return await getLocalComponents();
        // case "get_team_components":
        //   return await getTeamComponents();
        case "create_component_instance":
          return await createComponentInstance(params);
        case "export_node_as_image":
          return await exportNodeAsImage(params);
        case "set_corner_radius":
          return await setCornerRadius(params);
        case "set_text_content":
          return await setTextContent(params);
        case "clone_node":
          return await cloneNode(params);
        case "scan_text_nodes":
          return await scanTextNodes(params);
        case "set_multiple_text_contents":
          return await setMultipleTextContents(params);
        case "get_annotations":
          return await getAnnotations(params);
        case "set_annotation":
          return await setAnnotation(params);
        case "scan_nodes_by_types":
          return await scanNodesByTypes(params);
        case "set_multiple_annotations":
          return await setMultipleAnnotations(params);
        case "set_layout_mode":
          return await setLayoutMode(params);
        case "set_padding":
          return await setPadding(params);
        case "set_axis_align":
          return await setAxisAlign(params);
        case "set_layout_sizing":
          return await setLayoutSizing(params);
        case "set_item_spacing":
          return await setItemSpacing(params);
        default:
          throw new Error(`Unknown command: ${command}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. 'Create a new text element' implies a write/mutation operation, but there's no information about permissions required, whether this affects the Figma document permanently, error conditions, or what happens on success. The description doesn't mention if this creates a standalone element or how it integrates with the document structure beyond the parentId parameter.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with zero wasted words. It's front-loaded with the essential information (create text element) and doesn't include unnecessary elaboration. Every word earns its place in communicating the core purpose efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with 8 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what happens after creation (does it return an ID? success status?), doesn't mention error conditions or constraints, and provides no context about how this fits into Figma's document model. The description should do more to compensate for the lack of structured metadata.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 8 parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema - it doesn't explain relationships between parameters, provide examples of typical usage, or clarify semantics like coordinate systems or color format implications. The baseline of 3 is appropriate when the schema does all the parameter documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create') and resource ('new text element in Figma'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'set_text_content' or 'set_multiple_text_contents', which also manipulate text elements. The description is specific about what's being created but lacks sibling comparison.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There are multiple sibling tools that handle text (set_text_content, set_multiple_text_contents, scan_text_nodes) but no indication of when create_text is preferred over modifying existing text or when other creation tools (create_frame, create_rectangle) might be more appropriate. No prerequisites or context for usage are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/paragdesai1/parag-Figma-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server