get_selection
Retrieve details about currently selected elements in Figma designs to analyze or modify them through natural language commands.
Instructions
Get information about the current selection in Figma
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/cursor_mcp_plugin/code.js:137-147 (handler)Core handler function that retrieves the current Figma page selection, including count and basic node information (id, name, type, visible). This is the primary implementation of the get_selection logic.
async function getSelection() { return { selectionCount: figma.currentPage.selection.length, selection: figma.currentPage.selection.map((node) => ({ id: node.id, name: node.name, type: node.type, visible: node.visible, })), }; } - src/talk_to_figma_mcp/server.ts:61-87 (registration)MCP server tool registration for 'get_selection'. Defines the tool with empty input schema, proxies execution to Figma plugin via sendCommandToFigma, and formats the result as markdown text content.
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, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting selection: ${error instanceof Error ? error.message : String(error)}` } ] }; } } ); - src/cursor_mcp_plugin/code.js:66-67 (registration)Dispatch registration within the plugin's handleCommand switch statement, routing 'get_selection' commands to the getSelection handler function.
case "get_selection": return await getSelection(); - TypeScript union type FigmaCommand includes 'get_selection' as a valid command that can be sent to the Figma plugin.
| 'get_selection'