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"
Behavior2/5

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

Without annotations, the description alone must disclose behavioral traits. It does not mention that the node must be a text node, whether the tool modifies data, or any limitations. Only the basic action is stated.

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?

A single sentence that is direct and to the point with no superfluous words. The structure is efficient given the tool's simplicity.

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?

The tool has no output schema, so the description should explain the return format (e.g., list of segments with indices or offsets). It does not. The requirement that the node be a text node is also omitted, leaving the agent underinformed.

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 extra meaning beyond the schema; 'specific styling' is already conveyed by the property enum. No additional parameter details are provided.

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 the verb 'Get' and the resource 'text segments with specific styling', making the tool's purpose unambiguous. It distinguishes itself from siblings like 'scan_text_nodes' which scans for nodes, not styled segments.

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?

No guidance is provided on when to use this tool versus alternatives (e.g., get_node_info for full data). There are no exclusions or context cues about prerequisites or typical usage scenarios.

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/arinspunk/claude-talk-to-figma-mcp'

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