Skip to main content
Glama
yhc984
by yhc984

get_selection

Retrieve details about the currently selected elements in Figma, enabling real-time design analysis and integration with 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 executes the get_selection logic: returns selection count and basic node info (id, name, type, visible) from Figma's current page 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, })), }; }
  • MCP server.tool registration for 'get_selection': defines empty input schema, description, and proxy handler that forwards to Figma plugin via sendCommandToFigma and returns formatted text response.
    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)}` } ] }; } } );
  • Figma plugin's command dispatcher (handleCommand) that routes 'get_selection' to the getSelection handler function.
    async function handleCommand(command, params) { switch (command) { case "get_document_info": return await getDocumentInfo(); case "get_selection": return await getSelection(); case "get_node_info": if (!params || !params.nodeId) { throw new Error("Missing nodeId parameter"); } return await getNodeInfo(params.nodeId); case "create_rectangle": return await createRectangle(params); case "create_frame": return await createFrame(params); case "create_text": return await createText(params); case "set_fill_color": return await setFillColor(params); case "set_stroke_color": return await setStrokeColor(params); case "move_node": return await moveNode(params); case "resize_node": return await resizeNode(params); case "delete_node": return await deleteNode(params); case "get_styles": return await getStyles(); case "get_local_components": return await getLocalComponents(); case "get_team_components": return await getTeamComponents(); case "create_component_instance": return await createComponentInstance(params); case "export_node_as_image": return await exportNodeAsImage(params); case "execute_code": return await executeCode(params); case "set_corner_radius": return await setCornerRadius(params); default: throw new Error(`Unknown command: ${command}`); } }
  • Input schema for get_selection tool: empty object indicating no parameters required.
    server.tool( "get_selection", "Get information about the current selection in Figma", {},

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