Skip to main content
Glama

sketch_html_analyze

sketch_html_analyze

Analyzes Sketch HTML zip files to extract design structure, page layouts, and artboard information for design review and implementation.

Instructions

Analyze sketch html files and return the design structure of corresponding pages or drawing boards

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYessketch html zip file path(required)
page_idNopage id (optional)
page_nameNopage name (optional)
artboard_idNoartboard id (optional)
artboard_nameNoartboard name (optional)
rectNorect [x, y, width, height] (optional)
assets_pathNoassets path (optional), default src/assets/sketch
saveResultNosave analysis result (optional), default true

Implementation Reference

  • The actual implementation of the sketch_html_analyze logic which processes the file, filters artboards, and assembles data.
    export async function handleSketchHtmlAnalyze(args: SketchHtmlInputSchema) {
      let response = ''
    
      try {
        const sketchHtmlData = await openSketchHtmlFile(args.file_path)
        const targetArtboard = filterArtboards(args, sketchHtmlData.data.artboards)
        const assembledArtboard = assembleArtboard(
          targetArtboard,
          args.assets_path,
          args.rect,
          sketchHtmlData.images
        )
    
        const prompt = {
          meta: {
            description:
              'Design data extracted from Sketch exported HTML. All coordinates are relative to the artboard. Layers are flattened. Refer to the preview image to verify and refine the design structure.'
          },
          artboard: assembledArtboard.artboard
        }
    
        const parsed = path.parse(args.file_path)
        if (args.saveResult ?? true) {
          const targetPath = `${parsed.dir}/${parsed.name}/${assembledArtboard.artboard.pageName ?? assembledArtboard.artboard.pageObjectID}_${assembledArtboard.artboard.name ?? assembledArtboard.artboard.objectID}${args.rect?.length === 4 ? `[${args.rect.join(',')}]` : ''}.json`
          await writeJsonFile(targetPath, prompt)
        }
    
        response = `Sketch Structure JSON: ${JSON.stringify(prompt)}.`
    
        let previewPath = ''
    
        if (assembledArtboard.previewPath) {
          const imageData = sketchHtmlData.images?.find(item =>
            item.path.endsWith(assembledArtboard.previewPath)
          )?.data
          if (imageData) {
            const fileName = path.basename(assembledArtboard.previewPath)
            previewPath = `${parsed.dir}/${parsed.name}/${fileName}`
            response = `${response}\nSketch Preview Image: ${previewPath}`
            saveImage(imageData, `${parsed.dir}/${parsed.name}`, fileName).catch(
              error => {
                logger.error(`Failed to save image ${previewPath}: ${error}`)
              }
            )
          }
        }
      } catch (error) {
        response = `Sketch analyze error: ${error instanceof Error ? error.message : 'unknown error'}`
      }
    
      return response
    }
  • The tool wrapper function that invokes the core logic and formats it for the MCP protocol.
    async function sketchHtmlAnalyze(
      args: SketchHtmlInputSchema
    ): Promise<CallToolResult> {
      logger.debug(args, 'sketchHtmlAnalyze')
      const text = await handleSketchHtmlAnalyze(args)
      return {
        content: [
          {
            type: 'text',
            text
          }
        ]
      }
    }
  • Tool registration function that exposes the sketchHtmlAnalyze handler to the MCP tool registry.
    export function toolSketchHtmlAnalyze(): RegisterToolParams {
      return [
        toolName,
        {
          title: toolName,
          description:
            'Analyze sketch html files and return the design structure of corresponding pages or drawing boards',
          inputSchema: sketchHtmlInputSchema
        },
        sketchHtmlAnalyze
      ]
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but fails to specify critical traits: it doesn't clarify that the tool likely extracts/reads zip files (implied by 'sketch html zip file path'), doesn't explain what the saveResult parameter actually saves or where, and doesn't disclose whether this is a read-only operation or has side effects.

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 with no redundant words. It is appropriately front-loaded with the verb 'Analyze'. However, the density means it sacrifices clarity on parameter relationships and behavioral details that would require additional sentences.

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?

For an 8-parameter tool handling file processing with multiple optional filters (page, artboard, rect) and persistence options (saveResult), the description is inadequate. With no output schema provided, the description should explain the return format and structure, but it omits this entirely, leaving the agent uncertain about what data structure it will receive.

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, establishing a baseline of 3. The description adds marginal semantic value by referencing 'pages or drawing boards' which contextualizes the page_id and artboard_id parameters, but doesn't explain the rect parameter's purpose (cropping vs selection) or the assets_path behavior.

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 identifies the action ('Analyze') and resource ('sketch html files'), and mentions the return value ('design structure'). However, 'design structure' remains somewhat vague—it doesn't specify whether this returns layer hierarchies, CSS properties, or component trees, which would help the agent understand the utility of the output.

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 mentions 'pages or drawing boards' which implicitly maps to the page_id/artboard_id parameters, but provides no explicit guidance on when to use this tool versus alternatives, or how to use the filtering options (e.g., whether page_id and page_name are mutually exclusive or complementary).

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/YamadaAoi/mcp-sketch'

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