genart.dev
MCP ToolsSketch Lifecycle

fork_sketch

Create a variant of an existing sketch with a new ID, optionally applying modifications, and place it at a new position on the canvas.

Input Schema

ParameterTypeRequiredDescription
sourceIdstringyesID of the sketch to fork
newIdstringyesURL-safe kebab-case ID for the forked sketch
titlestringnoTitle for the fork (default: "[source title] (fork)")
position{ x: number, y: number }noCanvas position (default: auto-placed to the right of the source)
modificationsobjectnoFields to override in the fork (see below)
newSeedbooleannoGenerate a new random seed for the fork (default: true)

modifications object (all optional)

FieldTypeDescription
renderer'p5' | 'three' | 'glsl' | 'canvas2d' | 'svg'Change renderer type
canvas{ preset?, width?, height? }Override canvas dimensions
parametersParamDef[]Replace parameter definitions
colorsColorDef[]Replace color definitions
algorithmstringReplace algorithm code
philosophystringReplace philosophy text

Output Shape

{
  "success": true,
  "sourceId": "noise-grid",
  "forkedSketch": {
    "id": "noise-grid-v2",
    "title": "Noise Grid (fork)",
    "path": "/absolute/path/to/noise-grid-v2.genart",
    "renderer": "p5",
    "canvas": { "width": 1200, "height": 1200 },
    "seed": 73921,
    "position": { "x": 1400, "y": 0 }
  }
}

Side Effects

  • Creates a new .genart file on disk (in the same directory as the source)
  • Adds the forked sketch to the active workspace at the specified or auto-calculated position
  • Does not modify the source sketch

Error Cases

ConditionError
Source sketch not found"Sketch not found: 'bad-id'"
No workspace open"No workspace is currently open"
newId already exists in workspace"Sketch with ID 'noise-grid-v2' already exists in workspace"
newId contains invalid characters"ID must be kebab-case: lowercase letters, numbers, hyphens"
File already exists on disk"File already exists at /path/to/noise-grid-v2.genart"
Unknown renderer in modifications"Unknown renderer type: 'unity'. Valid types: p5, three, glsl, canvas2d, svg"

Golden Path Example

Request:

{
  "sourceId": "noise-grid",
  "newId": "noise-grid-circles",
  "title": "Noise Grid — Circle Variant",
  "newSeed": true,
  "modifications": {
    "algorithm": "function sketch(p, state) {\n  p.setup = () => {\n    p.createCanvas(state.canvas.width, state.canvas.height);\n    p.randomSeed(state.seed);\n    p.noiseSeed(state.seed);\n  };\n  p.draw = () => {\n    p.background(state.colorPalette[0]);\n    const n = state.params.cells;\n    const w = p.width / n;\n    for (let i = 0; i < n; i++)\n      for (let j = 0; j < n; j++) {\n        p.fill(p.noise(i*0.1, j*0.1) * 255);\n        p.noStroke();\n        p.ellipse(i*w + w/2, j*w + w/2, w*0.8);\n      }\n    p.noLoop();\n  };\n  return { initializeSystem() {} };\n}"
  }
}

Response:

{
  "success": true,
  "sourceId": "noise-grid",
  "forkedSketch": {
    "id": "noise-grid-circles",
    "title": "Noise Grid — Circle Variant",
    "path": "/Users/et/projects/genart/outputs/noise-grid-circles.genart",
    "renderer": "p5",
    "canvas": { "width": 1200, "height": 1200 },
    "seed": 48271,
    "position": { "x": 1400, "y": 0 }
  }
}