get_styled_text_segments
Extract text segments with specific styling from Figma text nodes, enabling precise design adjustments through AI-assisted interface interactions.
Instructions
Get text segments with specific styling in a text node
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- The handler function that executes the get_styled_text_segments tool by sending the corresponding command to Figma via websocket and returning the JSON stringified result.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 schema defining the input parameters for the tool: nodeId (string) and property (enum of 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"),
- src/talk_to_figma_mcp/tools/index.ts:17-17 (registration)Higher-level registration call that invokes registerTextTools to register all text tools, including get_styled_text_segments.registerTextTools(server);
- src/talk_to_figma_mcp/tools/text-tools.ts:450-494 (registration)Direct registration of the tool using server.tool() within the registerTextTools 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)}` } ] }; } } );
- Type definition for FigmaCommand union type includes this command name for type safety in sendCommandToFigma calls.| "get_styled_text_segments"