get_selection
Retrieve details about currently selected elements in Figma designs to analyze or process them programmatically.
Instructions
Get information about the current selection in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/talk_to_figma_mcp/server.ts:125-152 (registration)Registers the MCP tool 'get_selection'. The handler function proxies the call to Figma by invoking sendCommandToFigma('get_selection'), which sends the command over WebSocket to the Figma plugin. Returns the selection information as text content or an error message.server.tool( "get_selection", "Get information about the current selection in Figma", {}, async () => { try { const result = await sendCommandToFigma("get_selection"); return { content: [ { type: "text", text: JSON.stringify(result) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting selection: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
- src/talk_to_figma_mcp/server.ts:129-152 (handler)The handler is the inline async function that executes when the 'get_selection' tool is called. It sends the 'get_selection' command to the Figma plugin via sendCommandToFigma and formats the result as MCP content (JSON string of the selection data).async () => { try { const result = await sendCommandToFigma("get_selection"); return { content: [ { type: "text", text: JSON.stringify(result) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting selection: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } } );