Skip to main content
Glama
yhc984
by yhc984

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

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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, })), }; }
  • 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)}` } ] }; } } );
  • 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'

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yhc984/cursor-talk-to-figma-mcp-main'

If you have feedback or need assistance with the MCP directory API, please join our Discord server