Skip to main content
Glama

get_styled_text_segments

Extract text segments from Figma nodes based on specific styling properties like font, color, or spacing for design analysis and consistency checks.

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 handler function that executes the tool logic: sends 'get_styled_text_segments' command to Figma and returns the result as JSON-formatted text content or error message.
    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)}`
            }
          ]
        };
      }
    }
  • Zod input schema defining parameters: nodeId (string) and property (enum of specific style properties).
    {
      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"),
    },
  • Registration of the 'get_styled_text_segments' tool on the MCP server, specifying name, description, input schema, and handler function.
    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)}`
              }
            ]
          };
        }
      }
    );
  • TypeScript union type FigmaCommand includes 'get_styled_text_segments' for type safety in Figma websocket commands.
    export type FigmaCommand =
      | "get_document_info"
      | "get_selection"
      | "get_node_info"
      | "create_rectangle"
      | "create_frame"
      | "create_text"
      | "create_ellipse"
      | "create_polygon"
      | "create_star"
      | "create_vector"
      | "create_line"
      | "set_fill_color"
      | "set_stroke_color"
      | "move_node"
      | "resize_node"
      | "delete_node"
      | "get_styles"
      | "get_local_components"
      | "get_team_components"
      | "create_component_instance"
      | "export_node_as_image"
      | "join"
      | "set_corner_radius"
      | "clone_node"
      | "set_text_content"
      | "scan_text_nodes"
      | "set_multiple_text_contents"
      | "set_auto_layout"
      | "set_font_name"
      | "set_font_size"
      | "set_font_weight"
      | "set_letter_spacing"
      | "set_line_height"
      | "set_paragraph_spacing"
      | "set_text_case"
      | "set_text_decoration"
      | "get_styled_text_segments"
      | "load_font_async"
      | "get_remote_components"
      | "set_effects"
      | "set_effect_style_id"
      | "group_nodes"
      | "ungroup_nodes"
      | "flatten_node"
      | "insert_child";
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'analyzes' text nodes for styling, implying a read-only operation, but doesn't specify if it requires permissions, how it handles errors (e.g., invalid node IDs), or what the output format looks like (e.g., list of segments with style details). For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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, efficient sentence that front-loads the core purpose ('Get text segments with specific styling in a text node'). It uses no unnecessary words and directly communicates the tool's function without redundancy or fluff, making it easy to parse quickly.

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 tool's moderate complexity (2 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose but lacks details on behavioral aspects (e.g., error handling, output format) and usage guidelines. Without annotations or an output schema, the description should compensate more to ensure the agent can invoke it correctly, but it falls short of being fully comprehensive.

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%, with clear descriptions for both parameters ('nodeId' and 'property'), including an enum for 'property'. The description adds minimal value beyond the schema, mentioning 'specific styling' which aligns with the 'property' parameter but doesn't provide additional context like examples of style properties or how segments are defined. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('Get text segments') and the target ('in a text node'), specifying the filtering criterion ('with specific styling'). It distinguishes from siblings like 'get_node_info' or 'scan_text_nodes' by focusing on style analysis within text nodes. However, it doesn't explicitly contrast with all siblings, such as 'get_styles' which might retrieve style definitions rather than applied styles in text 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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a valid text node ID), exclusions (e.g., not for non-text nodes), or comparisons to siblings like 'get_styles' (for style definitions) or 'scan_text_nodes' (for broader text analysis). Usage is implied by the description but not explicitly defined.

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/agenisea/cc-fig-mcp'

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