Skip to main content
Glama

Preview SVG

preview

Convert SVG content to PNG images for visual verification during design iteration cycles. Use to inspect rendered output, validate visual results, and refine designs through render-preview-critique workflows.

Instructions

Render SVG content to a PNG image so the AI can visually inspect the output.

When to use:

  • After render_svg, call preview to see what was generated

  • Use in a revision loop: render → preview → critique → revise → preview again

  • Stop when the visual result matches the intent

Behavior:

  • Returns a PNG image (base64) rendered from the SVG string

  • Background is transparent by default

  • CSS animations and SMIL are rendered as a static snapshot (t=0) — motion is not captured

  • Format is auto-detected from content; pass format: "svg" explicitly if needed

Width:

  • Omit width to use the SVG's own declared width/viewBox

  • Pass width to scale the output (useful for small SVGs that need a larger preview)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesSVG string to render as PNG
formatNoContent format; auto-detected from content if omitted
widthNoRender width in pixels; defaults to SVG's own declared width

Implementation Reference

  • The handler logic for the 'preview' tool which calls `renderPreview` and returns the base64 encoded PNG image.
    async ({ content, format, width }) => {
      const start = Date.now();
      try {
        const pngBuffer = renderPreview(content, format, width);
        const base64 = pngBuffer.toString("base64");
        const elapsed = Date.now() - start;
        console.error(`[nakkas] preview OK — ${pngBuffer.length} bytes, ${elapsed}ms`);
        return {
          content: [{ type: "image", data: base64, mimeType: "image/png" }],
        };
      } catch (err) {
        const message = err instanceof Error ? err.message : String(err);
        console.error(`[nakkas] preview ERROR — ${message}`);
        return {
          content: [{ type: "text", text: `Error rendering preview: ${message}` }],
          isError: true,
        };
      }
    }
  • src/index.ts:154-188 (registration)
    The registration of the 'preview' MCP tool including its description and input schema.
    server.registerTool(
      "preview",
      {
        title: "Preview SVG",
        description: `
    Render SVG content to a PNG image so the AI can visually inspect the output.
    
    **When to use:**
    - After render_svg, call preview to see what was generated
    - Use in a revision loop: render → preview → critique → revise → preview again
    - Stop when the visual result matches the intent
    
    **Behavior:**
    - Returns a PNG image (base64) rendered from the SVG string
    - Background is transparent by default
    - CSS animations and SMIL are rendered as a static snapshot (t=0) — motion is not captured
    - Format is auto-detected from content; pass format: "svg" explicitly if needed
    
    **Width:**
    - Omit width to use the SVG's own declared width/viewBox
    - Pass width to scale the output (useful for small SVGs that need a larger preview)
        `.trim(),
        inputSchema: z.object({
          content: z.string().describe("SVG string to render as PNG"),
          format: z
            .enum(["svg", "html"])
            .optional()
            .describe("Content format; auto-detected from content if omitted"),
          width: z
            .number()
            .positive()
            .optional()
            .describe("Render width in pixels; defaults to SVG's own declared width"),
        }),
      },
Behavior5/5

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

No annotations are provided, so the description carries the full disclosure burden. It effectively communicates the return format ('PNG image (base64)'), default rendering behavior ('Background is transparent'), critical limitations ('CSS animations and SMIL are rendered as a static snapshot'), and auto-detection logic.

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 uses clear markdown headers (**When to use**, **Behavior**, **Width**) to segment information logically. It is front-loaded with the core purpose, uses efficient bullet points, and every sentence adds value. No redundant repetition of schema definitions occurs without adding new semantics.

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

Completeness5/5

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

Given the lack of output schema, the description compensates by explicitly stating the return value format (PNG base64). It covers all 3 parameters (including enum values and width scaling behavior), explains behavioral edge cases (animations), and provides workflow context. Complete for a preview/rendering tool of this complexity.

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

Parameters4/5

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

With 100% schema coverage, the baseline is 3. The description adds valuable usage context beyond the schema: specifically for the 'width' parameter, it explains the use case ('useful for small SVGs that need a larger preview') and clarifies the relationship between passed width vs. SVG's declared width/viewBox. For 'format', it adds guidance on when to pass it explicitly.

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

Purpose5/5

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

The description opens with a specific verb ('Render'), identifies the resource ('SVG content'), specifies the output format ('PNG image'), and clarifies the intent ('so the AI can visually inspect the output'). It clearly differentiates from sibling 'render_svg' by stating to call preview 'After render_svg' to see what was generated.

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

Usage Guidelines5/5

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

The 'When to use' section provides explicit workflow guidance including the sequence relationship with sibling tool render_svg, describes a revision loop pattern (render → preview → critique → revise), and defines a termination condition ('Stop when the visual result matches the intent').

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/arikusi/nakkas'

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