resolve_variable_by_name
Find variable IDs by name to bind design tokens like 'base-100' or 'primary' in Figma, enabling precise component styling and design system management.
Instructions
Find a variable ID by its name. Useful for binding variables when you know the semantic name (e.g., 'base-100', 'primary').
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name of the variable to find (e.g., 'base-100', 'primary', 'neutral') | |
| collectionName | No | Optional: Filter by collection name |
Implementation Reference
- src/talk_to_figma_mcp/tools/modification-tools.ts:629-661 (registration)Registration of the MCP tool 'resolve_variable_by_name' using server.tool(). Includes tool description, Zod input schema (name: string, optional collectionName: string), and handler that proxies the request to Figma via sendCommandToFigma and returns the JSON result or error message.server.tool( "resolve_variable_by_name", "Find a variable ID by its name. Useful for binding variables when you know the semantic name (e.g., 'base-100', 'primary').", { name: z.string().describe("The name of the variable to find (e.g., 'base-100', 'primary', 'neutral')"), collectionName: z.string().optional().describe("Optional: Filter by collection name") }, async ({ name, collectionName }) => { try { const result = await sendCommandToFigma("resolve_variable_by_name", { name, collectionName }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error resolving variable: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- The handler function executes the tool logic by sending a 'resolve_variable_by_name' command to the Figma plugin via websocket, stringifies the result as text response, or returns an error message.async ({ name, collectionName }) => { try { const result = await sendCommandToFigma("resolve_variable_by_name", { name, collectionName }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error resolving variable: ${error instanceof Error ? error.message : String(error)}` } ] }; } }
- Zod schema defining the input parameters for the tool: required 'name' (string) and optional 'collectionName' (string).{ name: z.string().describe("The name of the variable to find (e.g., 'base-100', 'primary', 'neutral')"), collectionName: z.string().optional().describe("Optional: Filter by collection name") },