Skip to main content
Glama

extract-color-vars

Extract color variables from Figma DSL files and export them to formats like UnoCSS, TailwindCSS, or custom standards for streamlined design-to-code workflows.

Instructions

从Figma DSL文件中提取颜色变量,并输出在用户指定的文件中(比如unocss、tailwindcss或者自定义标准文件中等)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileKeyYesThe key of the Figma file to fetch, often found in a provided URL like figma.com/(file|design)/<fileKey>/...
nodeIdNoThe ID of the node to fetch, often found as URL parameter node-id=<nodeId>, always use if provided

Implementation Reference

  • Handler function that executes the tool: fetches Figma DSL code using figmaToCode and constructs an XML prompt with extractColorVarsPrompt and the DSL for further processing.
    execute: async ({
      fileKey,
      nodeId,
    }, {
      session,
    }: {
      session: any
    }) => {
      try {
        const yamlResult = await this.figmaToolsCore.figmaToCode({
          fileKey,
          nodeId: nodeId || '',
        })
    
        const prompt: string = `
          <xml>
            <prompt>${extractColorVarsPrompt}</prompt>
            <Figma-DSL>${yamlResult}</Figma-DSL>
          </xml>
        `
    
        return {
          content: [
            { type: 'text', text: prompt },
          ],
        }
      } catch (error) {
        const message = error instanceof Error ? error.message : JSON.stringify(error)
        Logger.error(`Error fetching file ${fileKey}:`, message)
        return {
          isError: true,
          content: [{ type: 'text', text: `Error fetching file: ${message}` }],
        }
      }
    },
  • Zod schema defining the input parameters for the tool: fileKey (required) and nodeId (optional).
    parameters: z.object({
      fileKey: z
        .string()
        .describe(
          'The key of the Figma file to fetch, often found in a provided URL like figma.com/(file|design)/<fileKey>/...',
        ),
      nodeId: z
        .string()
        .optional()
        .describe(
          'The ID of the node to fetch, often found as URL parameter node-id=<nodeId>, always use if provided',
        ),
    }),
  • Full registration of the 'extract-color-vars' tool in UtilityTools class via this.server.addTool, called from registerTools().
    private extractColorVars(): void {
      this.server.addTool({
        name: 'extract-color-vars',
        description: '从Figma DSL文件中提取颜色变量,并输出在用户指定的文件中(比如unocss、tailwindcss或者自定义标准文件中等)',
        parameters: z.object({
          fileKey: z
            .string()
            .describe(
              'The key of the Figma file to fetch, often found in a provided URL like figma.com/(file|design)/<fileKey>/...',
            ),
          nodeId: z
            .string()
            .optional()
            .describe(
              'The ID of the node to fetch, often found as URL parameter node-id=<nodeId>, always use if provided',
            ),
        }),
        execute: async ({
          fileKey,
          nodeId,
        }, {
          session,
        }: {
          session: any
        }) => {
          try {
            const yamlResult = await this.figmaToolsCore.figmaToCode({
              fileKey,
              nodeId: nodeId || '',
            })
    
            const prompt: string = `
              <xml>
                <prompt>${extractColorVarsPrompt}</prompt>
                <Figma-DSL>${yamlResult}</Figma-DSL>
              </xml>
            `
    
            return {
              content: [
                { type: 'text', text: prompt },
              ],
            }
          } catch (error) {
            const message = error instanceof Error ? error.message : JSON.stringify(error)
            Logger.error(`Error fetching file ${fileKey}:`, message)
            return {
              isError: true,
              content: [{ type: 'text', text: `Error fetching file: ${message}` }],
            }
          }
        },
      })
    }
  • Invocation of extractColorVars() registration method within UtilityTools.registerTools().
    this.extractColorVars()
  • Import of the XML prompt template used in the tool's execute function.
    import extractColorVarsPrompt from './prompt/extract-color-vars.xml'
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 core functionality (extraction and output) but lacks details on permissions, rate limits, error handling, or what happens if the extraction fails. For a tool with no annotation coverage, this leaves significant gaps in understanding its operational behavior.

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

Conciseness4/5

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

The description is a single, efficient sentence that front-loads the main action ('extract color variables') and includes key details (source and output). There's no wasted text, though it could be slightly more structured by separating the output format examples into a clearer list.

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

Completeness2/5

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

Given the complexity of extracting and outputting color variables, no annotations, and no output schema, the description is incomplete. It doesn't explain the return values, error conditions, or how the output files are generated (e.g., file naming, overwrite behavior). This leaves the agent with insufficient context for reliable use.

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?

Schema description coverage is 100%, so the schema already documents both parameters (fileKey and nodeId) adequately. The description adds no additional parameter semantics beyond what's in the schema, such as explaining how these inputs relate to the extraction process or output formats. Baseline 3 is appropriate when the schema handles parameter documentation.

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 action ('extract color variables') and the resource ('from Figma DSL files'), and specifies the output destination ('in user-specified files'). However, it doesn't explicitly differentiate this tool from sibling tools like 'extract-svg-assets' or 'Figma-To-Code', which might have overlapping domains.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions output formats (unocss, tailwindcss, custom standards) but doesn't explain when to choose this extraction tool over other Figma-related tools on the server, nor does it mention any prerequisites or exclusions.

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

Related 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/Panzer-Jack/feuse-mcp'

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