get_selection
Retrieve details about the currently selected elements in Figma, enabling efficient design workflow integration between Cursor AI and Figma.
Instructions
Get information about the current selection in Figma
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/cursor_mcp_plugin/code.js:213-223 (handler)The core handler function for the 'get_selection' tool. It retrieves the current page selection in Figma and returns the count along with basic details (id, name, type, visible) for each selected node.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:97-124 (registration)MCP server registration of the 'get_selection' tool. Defines the tool name, description, empty input schema, and handler that proxies the command to the Figma plugin via WebSocket.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:109-110 (handler)Dispatch case in handleCommand function that routes 'get_selection' commands to the getSelection handler.case "get_selection": return await getSelection();
- Empty input schema for the 'get_selection' tool (no parameters required).{},