get_local_components
Retrieve all local components from a Figma document to access and manage design elements programmatically using the Talk to Figma MCP server.
Instructions
Get all local components from the Figma document
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/cursor_mcp_plugin/code.js:610-623 (handler)Core handler function that executes the 'get_local_components' tool logic: finds all COMPONENT nodes in the Figma document root and returns a list with count, ids, names, and keys.async function getLocalComponents() { 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:473-499 (registration)MCP server registration of the 'get_local_components' tool, which has no input schema and proxies the command to the Figma plugin via sendCommandToFigma, formatting the result as MCP 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, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting local components: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- src/cursor_mcp_plugin/code.js:91-92 (handler)Dispatch handler in the plugin's command switch statement that routes 'get_local_components' calls to the getLocalComponents function.case "get_local_components": return await getLocalComponents();