Skip to main content
Glama
yhc984
by yhc984

get_node_info

Retrieve detailed information about a specific node in Figma using its node ID, enabling precise design data access for analysis or integration.

Instructions

Get detailed information about a specific node in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the node to get information about

Implementation Reference

  • Core handler function that retrieves detailed information about a Figma node using the Figma API, including position, size, fills, strokes, children, and text properties.
    async function getNodeInfo(nodeId) { const node = await figma.getNodeByIdAsync(nodeId); if (!node) { throw new Error(`Node not found with ID: ${nodeId}`); } // Base node information const nodeInfo = { id: node.id, name: node.name, type: node.type, visible: node.visible, }; // Add position and size for SceneNode if ("x" in node && "y" in node) { nodeInfo.x = node.x; nodeInfo.y = node.y; } if ("width" in node && "height" in node) { nodeInfo.width = node.width; nodeInfo.height = node.height; } // Add fills for nodes with fills if ("fills" in node) { nodeInfo.fills = node.fills; } // Add strokes for nodes with strokes if ("strokes" in node) { nodeInfo.strokes = node.strokes; if ("strokeWeight" in node) { nodeInfo.strokeWeight = node.strokeWeight; } } // Add children for parent nodes if ("children" in node) { nodeInfo.children = node.children.map((child) => ({ id: child.id, name: child.name, type: child.type, })); } // Add text-specific properties if (node.type === "TEXT") { nodeInfo.characters = node.characters; nodeInfo.fontSize = node.fontSize; nodeInfo.fontName = node.fontName; } return nodeInfo; }
  • MCP tool registration for 'get_node_info', including schema validation for nodeId input and handler that proxies the command to the Figma plugin via WebSocket.
    server.tool( "get_node_info", "Get detailed information about a specific node in Figma", { nodeId: z.string().describe("The ID of the node to get information about") }, async ({ nodeId }) => { try { const result = await sendCommandToFigma('get_node_info', { nodeId }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting node info: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
  • Dispatch case in the Figma plugin's command handler that routes 'get_node_info' calls to the getNodeInfo function.
    case "get_node_info": if (!params || !params.nodeId) { throw new Error("Missing nodeId parameter"); } return await getNodeInfo(params.nodeId);
  • Zod schema for input validation of the nodeId parameter in the MCP tool.
    { nodeId: z.string().describe("The ID of the node to get information about")

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