Skip to main content
Glama

extract-svg-assets

Extract SVG assets from Figma files by analyzing the SDL structure and downloading resources using specified file keys and node IDs.

Instructions

分析figma SDL中的结构,并调用download-svg-assets工具下载Figma文件中使用的SVG资源

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

  • The main handler function for the 'extract-svg-assets' tool. It fetches the Figma DSL (YAML) for the given fileKey and optional nodeId, then constructs an XML prompt using the imported extractSVGAssetsPrompt and the DSL, returning it as text content.
    execute: async ({
      fileKey,
      nodeId,
    }, {
      session,
    }: {
      session: any
    }) => {
      try {
        const yamlResult = await this.figmaToolsCore.figmaToCode({
          fileKey,
          nodeId: nodeId || '',
        })
    
        const prompt: string = `
          <xml>
            <prompt>${extractSVGAssetsPrompt}</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: required fileKey (Figma file key) and optional nodeId (node ID).
    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',
        ),
    }),
  • The private method that registers the 'extract-svg-assets' tool on the MCP server using server.addTool().
    private extractSVGAssets(): void {
      this.server.addTool({
        name: 'extract-svg-assets',
        description: '分析figma SDL中的结构,并调用download-svg-assets工具下载Figma文件中使用的SVG资源',
        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>${extractSVGAssetsPrompt}</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}` }],
            }
          }
        },
      })
    }
  • Call to register the extract-svg-assets tool within the public registerTools() method of UtilityTools class.
    this.extractSVGAssets()
  • Import of the prompt template XML file used within the tool handler to instruct on extracting SVG assets.
    import extractSVGAssetsPrompt from './prompt/extract-svg-assets.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 mentions analyzing structure and calling another tool, but doesn't describe what 'analyzing' entails (e.g., parsing, filtering, or processing), whether it requires authentication, rate limits, error handling, or what happens if the nodeId is omitted. For a tool with no annotations, this leaves significant gaps in understanding its behavior and constraints.

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 a single, efficient sentence in Chinese that directly states the tool's purpose and action. It's front-loaded with the main function (analyze and call), with no redundant or unnecessary information. Every word earns its place, making it highly concise and well-structured.

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 analyzing Figma SDL and calling another tool, with no annotations and no output schema, the description is incomplete. It doesn't explain what 'analyzing' involves, the output format (e.g., list of assets, status), error conditions, or dependencies on the 'download-svg-assets' tool. For a tool that performs analysis and orchestration, more context is needed to understand its full behavior and results.

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 schema description coverage is 100%, with clear descriptions for both parameters (fileKey and nodeId). The description doesn't add any parameter-specific details beyond what the schema provides, such as explaining how the analysis uses these inputs or their impact on the tool's behavior. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate with additional semantic context.

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: '分析figma SDL中的结构,并调用download-svg-assets工具下载Figma文件中使用的SVG资源' (Analyze the structure of a Figma SDL and call the download-svg-assets tool to download SVG resources used in the Figma file). It specifies the verb (analyze and call), resource (Figma SDL structure), and outcome (download SVG resources). However, it doesn't explicitly distinguish this from sibling tools like 'download-svg-assets' or 'Figma-To-Code', which might have overlapping functionality.

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 implies usage by mentioning that it calls 'download-svg-assets' for downloading SVG resources, suggesting it's for extracting assets from Figma files. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'download-svg-assets' directly or other siblings such as 'extract-color-vars'. No exclusions or prerequisites are stated, leaving usage context somewhat vague.

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