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'

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