get_selection
Retrieve details about currently selected elements in Figma to enable AI-assisted design analysis and modifications.
Instructions
Get information about the current selection in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The core handler function for the 'get_selection' tool. It sends the 'get_selection' command to the Figma plugin using sendCommandToFigma and returns the result as JSON-formatted text content. Includes try-catch for error handling.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/tools/document-tools.ts:41-67 (registration)The registration of the 'get_selection' tool using server.tool(), specifying name, description, empty input schema ({}), and the handler function. This is called within registerDocumentTools.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/tools/index.ts:14-14 (registration)Call to registerDocumentTools from the main registerTools function, which performs the tool registrations including get_selection.registerDocumentTools(server);
- src/talk_to_figma_mcp/server.ts:34-34 (registration)Invocation of registerTools(server) in the main server setup, which chains to the registration of get_selection.registerTools(server);
- The 'get_selection' command is included in the FigmaCommand type union, used for type safety in command handling.| "get_selection"