Skip to main content
Glama

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
NameRequiredDescriptionDefault
nameYesThe name of the variable to find (e.g., 'base-100', 'primary', 'neutral')
collectionNameNoOptional: Filter by collection name

Implementation Reference

  • 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")
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes the tool as a lookup operation ('Find'), which implies it's read-only and non-destructive, but doesn't explicitly state this. It also doesn't cover potential behaviors like error handling (e.g., if the variable doesn't exist), return format, or any rate limits. For a tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: two sentences that directly state the purpose and usage context without unnecessary details. Every sentence earns its place by providing essential information, making it efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (a simple lookup with 2 parameters) and no output schema, the description is moderately complete. It covers the basic purpose and usage but lacks details on behavioral aspects (e.g., what happens if the variable isn't found) and doesn't explain return values. With no annotations and no output schema, it should do more to compensate, but it's adequate for a straightforward tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with clear descriptions for both parameters ('name' and 'collectionName'). The description adds minimal value beyond the schema: it provides examples ('e.g., 'base-100', 'primary') which are already in the schema, and mentions 'semantic name' but doesn't clarify what that means. With high schema coverage, the baseline is 3, and the description doesn't significantly enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Find a variable ID by its name.' It specifies the verb ('Find') and resource ('variable ID'), and distinguishes it from siblings like 'get_bound_variables' by focusing on lookup by name rather than listing bound variables. However, it doesn't explicitly differentiate from other variable-related tools (none in the sibling list), so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance: 'Useful for binding variables when you know the semantic name.' This suggests a context (binding variables) but doesn't explicitly state when to use this tool versus alternatives like 'get_bound_variables' or other variable-handling methods. No exclusions or clear alternatives are mentioned, making it adequate but not comprehensive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/agenisea/cc-fig-mcp'

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