get_local_components
Retrieve all local components from a Figma document to access reusable design elements within the Cursor AI and Figma integration.
Instructions
Get all local components from the Figma document
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_local_components"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/talk_to_figma_mcp/server.ts:941-969 (registration)MCP server tool registration. Defines the tool schema (empty params) and handler function that forwards the request to the Figma plugin via sendCommandToFigma WebSocket proxy.
// Get Local Components Tool server.tool( "get_local_components", "Get all local components from the Figma document", {}, async () => { try { const result = await sendCommandToFigma("get_local_components"); return { content: [ { type: "text", text: JSON.stringify(result) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting local components: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } } ); - src/cursor_mcp_plugin/code.js:888-903 (handler)Core implementation of get_local_components in the Figma plugin. Loads all pages and finds all COMPONENT nodes using figma.root.findAllWithCriteria, returns count and list with id, name, key.
async function getLocalComponents() { await figma.loadAllPagesAsync(); const components = figma.root.findAllWithCriteria({ types: ["COMPONENT"], }); return { count: components.length, components: components.map((component) => ({ id: component.id, name: component.name, key: "key" in component ? component.key : null, })), }; } - src/cursor_mcp_plugin/code.js:143-144 (handler)Dispatch registration in Figma plugin's handleCommand switch that calls the getLocalComponents handler.
case "get_local_components": return await getLocalComponents();