Skip to main content
Glama
yhc984
by yhc984

get_local_components

Retrieve all local components from a Figma document to access reusable design elements for integration or modification.

Instructions

Get all local components from the Figma document

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that retrieves all local COMPONENT nodes from the Figma document root using findAllWithCriteria, and returns a structured 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, })), }; }
  • MCP server registration of the 'get_local_components' tool, which proxies the command to the Figma plugin via WebSocket and formats the response 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)}` } ] }; } } );
  • Dispatch case in the Figma plugin's handleCommand function that routes 'get_local_components' to the getLocalComponents handler.
    case "get_local_components": return await getLocalComponents();
  • Input schema for the tool (empty object, no parameters required).
    {},
  • Inclusion of 'get_local_components' in the FigmaCommand type union for TypeScript type safety.
    | 'get_local_components'

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