MCP ToolsExport
export_sketch
Export a sketch as a standalone HTML file, raw algorithm code, PNG image, or SVG — producing a self-contained artifact viewable outside the genart editor.
Input Schema
| Parameter | Type | Required | Description |
|---|---|---|---|
sketchId | string | yes | ID of the sketch to export |
format | 'html' | 'png' | 'svg' | 'algorithm' | 'zip' | yes | Export format |
outputPath | string | yes | File path to write the export |
width | number | no | Override width for PNG/SVG export (default: sketch canvas width) |
height | number | no | Override height for PNG/SVG export (default: sketch canvas height) |
seed | number | no | Override seed for this export (default: sketch's current seed) |
params | object | no | Override params for this export (default: sketch's current params) |
Format details
- html: Self-contained HTML file with the renderer runtime loaded from CDN (p5.js, three.js, etc.), all metadata inlined, and the algorithm embedded. Opens in any browser.
- png: Rendered PNG at specified or canvas dimensions.
- svg: For SVG-renderer sketches, the raw SVG output. For other renderers, a rasterized PNG embedded in an SVG container.
- algorithm: Raw algorithm source code as a plain text file (
.jsor.glsldepending on renderer). - zip: All of the above bundled together plus the
.genartsource file.
Output Shape
{
"success": true,
"sketchId": "noise-grid",
"format": "html",
"outputPath": "/absolute/path/to/noise-grid.html",
"fileSize": 24576,
"renderer": "p5"
}Side Effects
- Writes one or more files to
outputPath - For
htmlformat: fetches no external resources at export time (CDN URLs are embedded as<script src>tags) - For
pngformat: renders the sketch headlessly to produce the image - Does not modify the source
.genartfile
Error Cases
| Condition | Error |
|---|---|
| Sketch not found | "Sketch not found: 'bad-id'" |
| No workspace open | "No workspace is currently open" |
outputPath parent directory doesn't exist | "Parent directory does not exist: /bad/path" |
File already exists at outputPath | "File already exists at /path/to/file. Delete it first or use a different path." |
| Renderer fails during PNG capture | "Renderer error for 'noise-grid': [error message]" |
| SVG format for non-SVG renderer (returns PNG-in-SVG) | Not an error — falls back to rasterized export with a notice |
Golden Path Example
Request:
{
"sketchId": "noise-grid",
"format": "html",
"outputPath": "~/projects/genart/outputs/noise-grid-export.html"
}Response:
{
"success": true,
"sketchId": "noise-grid",
"format": "html",
"outputPath": "/Users/et/projects/genart/outputs/noise-grid-export.html",
"fileSize": 24576,
"renderer": "p5"
}Exported HTML structure (abbreviated):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Noise Grid — genart.dev</title>
<style>body { margin: 0; background: #1a1a1a; display: flex; justify-content: center; align-items: center; height: 100vh; }</style>
<script src="https://cdn.jsdelivr.net/npm/p5@1/lib/p5.min.js"></script>
</head>
<body>
<main id="sketch-container"></main>
<script>
const state = { /* serialized sketch state */ };
const sketchFn = function sketch(p, state) { /* algorithm */ };
new p5((p) => sketchFn(p, state), document.getElementById('sketch-container'));
</script>
</body>
</html>snapshot_layout
Return a structural summary of the workspace layout — all sketches with positions, sizes, renderer types, groups, and bounding box — without full algorithm or philosophy content.
merge_sketches
Combine parameters, colors, and algorithm elements from two or more source sketches into a new sketch, using a configurable merge strategy.