get_styles
Extract all styles from the current Figma document, enabling programmatic access and integration with Cursor AI for efficient design management.
Instructions
Get all styles from the current Figma document
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
- src/talk_to_figma_mcp/server.ts:912-939 (handler)MCP tool handler for 'get_styles'. Forwards the command to the Figma plugin via sendCommandToFigma WebSocket proxy and returns the JSON result as text content.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) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting styles: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
- src/talk_to_figma_mcp/server.ts:912-912 (registration)Registers the MCP tool 'get_styles' with empty input schema.server.tool(
- src/cursor_mcp_plugin/code.js:853-886 (handler)Actual implementation of get_styles in Figma plugin: retrieves local paint, text, effect, and grid styles from the document.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:141-142 (registration)Dispatches 'get_styles' command to the getStyles handler function in Figma plugin code.case "get_styles": return await getStyles();