get_selection
Retrieve details about currently selected elements in Figma designs to enable programmatic reading and modification through Cursor AI integration.
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:97-124 (registration)Registers the MCP tool 'get_selection'. The handler is a thin proxy that calls sendCommandToFigma("get_selection") via WebSocket to the Figma plugin and returns the result as 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) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting selection: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
- src/cursor_mcp_plugin/code.js:213-223 (handler)Core handler implementation in Figma plugin. Returns the count of selected nodes and array of basic info objects (id, name, type, visible) from figma.currentPage.selection.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/cursor_mcp_plugin/code.js:109-110 (handler)Dispatch in handleCommand switch statement that routes 'get_selection' commands to the getSelection() handler.case "get_selection": return await getSelection();