Skip to main content
Glama

Render SVG

render_svg

Convert JSON configuration into animated SVG graphics with CSS and SMIL animations, supporting parametric curves, pattern groups, gradients, and filters for dynamic visual design.

Instructions

Render animated SVG from JSON config. AI controls all design parameters.

Workflow: render_svg > preview > critique > revise. Iterate at least 3 times before finalizing.

Element types: rect, circle, ellipse, line, polyline, polygon, path, image, text, textPath, group, use, radial-group, arc-group, grid-group, scatter-group, path-group, parametric

Pattern groups (use for repetitive designs): radial-group (circular), arc-group (arc), grid-group (matrix), scatter-group (random), path-group (along polyline). Each takes count + child element.

Parametric curves (fn field): rose, heart, lissajous, spiral, star, superformula, hypotrochoid, wave. Server computes coordinates.

defs: gradients (linear/radial, SMIL animated stops), filters (presets: glow, neon, blur, drop-shadow, glitch, chromatic-aberration, noise, outline, inner-shadow, emboss + 5 more), clipPaths, masks, patterns (tile fills).

Animations: CSS @keyframes via animations array. Set cssClass on element matching animation name. For transforms add transformBox="fill-box" transformOrigin="center". SMIL via smilAnimations on elements (animate, animateTransform, animateMotion).

Critical format rules:

  • Gradient type must be "linearGradient" or "radialGradient" (not "linear"/"radial"). Each needs id, stops (array with offset 0-1, color).

  • Filter type must be "preset" with a "preset" field: {"type":"preset","id":"myGlow","preset":"glow","stdDeviation":8,"color":"#ff00ff"}

  • Keyframe offset: use "from"/"to" or percentage number 0-100 (not "0%"/"100%").

  • Colors: hex only (#rrggbb or #rrggbbaa). No rgb(), no named colors.

  • Every element needs "type" field. circle needs r, rect needs width+height, path needs d.

Output: Pure SVG XML. No JavaScript. CSS @keyframes + SMIL only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
canvasYes
defsNo
elementsYes
animationsNo

Implementation Reference

  • The primary function `renderSVG` implementation for the tool `render_svg`.
    export function renderSVG(config: SVGConfig): string {
      const canvas = config.canvas;
    
      // Build root <svg> attributes
      const svgAttrs = attrs({
        xmlns: canvas.xmlns ?? "http://www.w3.org/2000/svg",
        width: length(canvas.width),
        height: length(canvas.height),
        viewBox: canvas.viewBox,
        preserveAspectRatio: canvas.preserveAspectRatio,
      } as Record<string, string | number | boolean | null | undefined>);
    
      // Render sections
      const defsBlock = renderDefs(config);
      const styleBlock = renderCSSAnimations(config.animations ?? []);
      const backgroundRect = renderBackground(config);
      const elementBlocks = config.elements.map(renderAnyElement);
    
      // Assemble body
      const bodyParts: string[] = [];
      if (defsBlock) bodyParts.push(defsBlock);
      if (styleBlock) bodyParts.push(styleBlock);
      if (backgroundRect) bodyParts.push(backgroundRect);
      bodyParts.push(...elementBlocks);
    
      const body = bodyParts.join("\n");
      const indentedBody = body
        .split("\n")
        .map((line) => (line.trim() ? `  ${line}` : ""))
        .join("\n");
    
      return `<svg ${svgAttrs}>\n${indentedBody}\n</svg>`;
    }
Behavior4/5

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

With no annotations provided, the description carries full disclosure burden. It specifies output format ('Pure SVG XML. No JavaScript'), computation delegation ('Server computes coordinates'), and temporal behavior (iterative workflow). Minor gap: does not explicitly state if output is returned directly or stored, though implied by 'Output: Pure SVG XML'.

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?

Dense with necessary information given zero schema documentation. Uses markdown headers to segment complex domains (workflow, element types, parametric curves, critical rules). Length is justified by complexity, though some repetition exists between element lists and critical rules. Front-loaded with workflow context before technical deep-dive.

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?

Remarkably complete for a complex creative tool. Covers: valid enum values, pattern syntax for groups, coordinate computation methods, animation techniques (CSS vs SMIL), color/ID format constraints, and output schema expectations. Absence of output schema is mitigated by explicit 'Output: Pure SVG XML' declaration and detailed input specifications.

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

Parameters5/5

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

Compensates completely for 0% schema description coverage. The text enumerates valid element types (15+ values), parameter constraints (hex colors only, linearGradient vs linear), required fields per type (circle needs 'r'), and complex nested structures for animations/defs. Critical format rules section maps directly to schema properties with validation requirements.

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-resource combo ('Render animated SVG') and scope ('from JSON config'), immediately clarifying the tool's function. It distinguishes itself from siblings via the explicit workflow line 'render_svg > preview > critique > revise', establishing its place in a multi-step sequence.

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?

Provides explicit workflow guidance including iteration requirements ('Iterate at least 3 times before finalizing') and sequences the tool relative to siblings ('render_svg > preview'). This clearly signals when to invoke the tool (generation phase) and what must follow (preview).

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