Skip to main content
Glama
arinspunk

Claude Talk to Figma MCP

by arinspunk

get_styled_text_segments

Analyze a Figma text node to extract segments that match a specified style property, such as font size or fill color, for targeted design inspection and adjustments.

Instructions

Get text segments with specific styling in a text node

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the text node to analyze
propertyYesThe style property to analyze segments by

Implementation Reference

  • The get_styled_text_segments tool handler registered on the MCP server. It accepts nodeId and property parameters, sends the command to Figma via WebSocket, and returns the styled text segments result as JSON.
    // Get Styled Text Segments Tool
    server.tool(
      "get_styled_text_segments",
      "Get text segments with specific styling in a text node",
      {
        nodeId: z.string().describe("The ID of the text node to analyze"),
        property: z.enum([
          "fillStyleId", 
          "fontName", 
          "fontSize", 
          "textCase", 
          "textDecoration", 
          "textStyleId", 
          "fills", 
          "letterSpacing", 
          "lineHeight", 
          "fontWeight"
        ]).describe("The style property to analyze segments by"),
      },
      async ({ nodeId, property }) => {
        try {
          const result = await sendCommandToFigma("get_styled_text_segments", {
            nodeId,
            property
          });
          
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(result, null, 2)
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error getting styled text segments: ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • Input schema for the tool using Zod: nodeId (string) and property (enum of fillStyleId, fontName, fontSize, textCase, textDecoration, textStyleId, fills, letterSpacing, lineHeight, fontWeight).
    {
      nodeId: z.string().describe("The ID of the text node to analyze"),
      property: z.enum([
        "fillStyleId", 
        "fontName", 
        "fontSize", 
        "textCase", 
        "textDecoration", 
        "textStyleId", 
        "fills", 
        "letterSpacing", 
        "lineHeight", 
        "fontWeight"
      ]).describe("The style property to analyze segments by"),
    },
  • Tool registered via server.tool('get_styled_text_segments', ...) inside registerTextTools(). The registerTextTools function is called from tools/index.ts which is called from server.ts.
    // Get Styled Text Segments Tool
    server.tool(
      "get_styled_text_segments",
      "Get text segments with specific styling in a text node",
      {
        nodeId: z.string().describe("The ID of the text node to analyze"),
        property: z.enum([
          "fillStyleId", 
          "fontName", 
          "fontSize", 
          "textCase", 
          "textDecoration", 
          "textStyleId", 
          "fills", 
          "letterSpacing", 
          "lineHeight", 
          "fontWeight"
        ]).describe("The style property to analyze segments by"),
      },
      async ({ nodeId, property }) => {
        try {
          const result = await sendCommandToFigma("get_styled_text_segments", {
            nodeId,
            property
          });
          
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(result, null, 2)
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error getting styled text segments: ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • sendCommandToFigma function that sends the command over WebSocket and returns a promise. The get_styled_text_segments handler calls this with command type 'get_styled_text_segments'.
    export function sendCommandToFigma(
      command: FigmaCommand,
      params: unknown = {},
      timeoutMs: number = 300000
    ): Promise<unknown> {
  • Type definition: 'get_styled_text_segments' is listed as a valid FigmaCommand in the union type, ensuring type safety for command routing.
    | "get_styled_text_segments"

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.2
    • addedInput schema / additionalProperties
      Added value: +false
  2. Changed4 schema fields changedv1.0.0
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / nodeId
      Added value: +{
      +  "description": "The ID of the text node to analyze",
      +  "type": "string"
      +}
    • addedInput schema / properties / property
      Added value: +{
      +  "description": "The style property to analyze segments by",
      +  "enum": [
      +    "fillStyleId",
      +    "fontName",
      +    "fontSize",
      +    "textCase",
      +    "textDecoration",
      +    "textStyleId",
      +    "fills",
      +    "letterSpacing",
      +    "lineHeight",
      +    "fontWeight"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / required
      Added value: +[
      +  "nodeId",
      +  "property"
      +]
  3. First observed

TDQS

A3.5/5.0
Behavior2/5

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

No annotations are provided, so the description carries full burden. However, it only states the function without disclosing behavioral traits such as what happens with invalid nodeId, whether it is a read-only operation, or if there are any side effects. The simplicity leaves ambiguity about error handling and output nature.

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, direct sentence with no extraneous information. It is appropriately sized for the tool's simplicity and front-loaded with the core action.

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

Completeness3/5

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

Given the lack of output schema and annotations, the description omits details about return format, pagination, or error behavior. While the tool is simple, the description is minimally adequate but leaves gaps that could be filled with more context.

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 baseline is 3. The description adds no additional meaning beyond what the schema already provides; it merely restates the purpose without elaborating on parameter values or usage nuances.

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

Purpose5/5

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

The description clearly states it gets text segments with specific styling within a text node. The verb 'Get' and resource 'text segments with specific styling' are specific. Among siblings, 'scan_text_nodes' is broader, so this tool is clearly distinguished.

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

Usage Guidelines3/5

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

The description implies usage when needing to analyze styled segments in a specific text node, but it does not provide explicit instructions on when to use this tool versus alternatives like 'scan_text_nodes' or 'get_node_info'. No when-not or prerequisites are mentioned.

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

Deploy Server

Other Tools