get_styles
Extract all styles from a Figma document to access and utilize design information programmatically within the Talk to Figma MCP server.
Instructions
Get all styles from the current Figma document
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/cursor_mcp_plugin/code.js:575-608 (handler)Core implementation of get_styles: retrieves local paint, text, effect, and grid styles from Figma using API calls and returns formatted list.async function getStyles() { const styles = { colors: await figma.getLocalPaintStylesAsync(), texts: await figma.getLocalTextStylesAsync(), effects: await figma.getLocalEffectStylesAsync(), grids: await figma.getLocalGridStylesAsync(), }; return { colors: styles.colors.map((style) => ({ id: style.id, name: style.name, key: style.key, paint: style.paints[0], })), texts: styles.texts.map((style) => ({ id: style.id, name: style.name, key: style.key, fontSize: style.fontSize, fontName: style.fontName, })), effects: styles.effects.map((style) => ({ id: style.id, name: style.name, key: style.key, })), grids: styles.grids.map((style) => ({ id: style.id, name: style.name, key: style.key, })), }; }
- src/cursor_mcp_plugin/code.js:89-90 (handler)Dispatches the 'get_styles' command in the Figma plugin's handleCommand switch statement to the getStyles function.case "get_styles": return await getStyles();
- src/talk_to_figma_mcp/server.ts:444-470 (registration)Registers the 'get_styles' MCP tool with no input schema; handler proxies to Figma plugin via sendCommandToFigma and formats response.server.tool( "get_styles", "Get all styles from the current Figma document", {}, async () => { try { const result = await sendCommandToFigma('get_styles'); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting styles: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- Input schema for get_styles tool: empty object (no parameters required).{},
- Includes 'get_styles' in the FigmaCommand type union for type safety.| 'get_styles'