get_local_components
Retrieve all local components from a Figma document to enable Cursor AI to programmatically access and modify design elements directly within Figma.
Instructions
Get all local components from the Figma document
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- src/cursor_mcp_plugin/code.js:888-902 (handler)The main handler function that implements the get_local_components tool by loading all Figma pages and finding all COMPONENT nodes in the document root, returning their count and basic details (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/talk_to_figma_mcp/server.ts:942-969 (registration)Registers the MCP tool 'get_local_components' with empty input schema, forwarding the call to the Figma plugin via sendCommandToFigma and returning the result as text content.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:143-144 (handler)Dispatch case in handleCommand switch that routes 'get_local_components' command to the getLocalComponents handler function.case "get_local_components": return await getLocalComponents();