Skip to main content
Glama

Cursor Talk to Figma MCP

by paragdesai1

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

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {}, "type": "object" }

Implementation Reference

  • 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, })), };
  • 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) }`, }, ], }; } } );
  • Dispatch case in handleCommand switch that routes 'get_local_components' command to the getLocalComponents handler function.
    case "get_local_components": return await getLocalComponents();

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/paragdesai1/parag-Figma-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server