Skip to main content
Glama

execute

Run JavaScript programs in Aseprite to create sprites, draw pixel art, animate frames, and export sheets or GIFs, with each program committed as one undo step.

Instructions

Draw pixel art live in the user's Aseprite by running a JavaScript program. Coordinates are 0-based, (0,0) top-left; frames are 0-based.

Globals: sprite(o?: { new?: [w, h]; colorMode?: "rgb"|"indexed"|"gray"; open?: path; id?: number; name?: string }): Promise // no args = the active sprite sprites(): Promise<{ id, name, width, height, frames, active }[]> image(path): Promise // load a PNG reference: Image { image, width, height, read(o?), colors(max = 32), downscale(factor) } ramp(base: string, keys: string, o?: { hueShift?: number }): Record<string, string> // OKLCH shades, dark to light, one per key palette(name, colors?): Promise<Record<string, string>> // load, or save with colors, a named palette lib(name?, code?): Promise<string[] | string> // save helper code: lib(name, code); read: lib(name); list: lib() use(name): void // top-level use("style") puts a saved library's functions in scope; see help("lib") help(topic?): string // topics: maps, animation, critique, conflicts, files, export, lib

Sprite { id, name, width, height, colorMode layers(): string[] // paths, bottom to top; "group/child" frames(): number; selection(): Rect | null cel(layer, frame = 0): Cel; cels(layer): Cel[] // one per frame layer(name, o?: { below?, visible?, opacity? (0-255), rename?, remove? }): void // unknown name = new layer setFrames(count, o?: { duration?: ms | ms[] }): void // new frames copy the last frame tag(name, from, to, o?: { direction?: "forward"|"reverse"|"pingpong" }): void view(o?: { frame?: number | "all"; rect?: Rect; scale?: number; critique?: boolean; background?: "#080707" }): Promise<{ path, width, height }> // background replaces the checkerboard resize(w, h, o?: { x?, y? }): Sprite // canvas size, not scale; art moves by (x, y), default bottom-centred; use the returned handle commit(label?): Promise<{ label, cels, pixels, merged, lost }> // checkpoint now undo(n = 1): Promise; redo(n = 1): Promise changes(): Promise<{ layer, frame, rect, palette, rows }[]> // the artist's edits since you last looked save(nameOrPath?): Promise // save("slime") -> ~/Pictures/aseprite-mcp/slime.aseprite export(name, o?: { scale?, tag?, sheet? = true, gif?, columns? }): Promise<{ sheet?, json?, gif?, frames, width, height }> } // sprite sheet PNG + JSON, GIF Cel { layer, frame map(palette, rows, o?: { x?, y?, flip?: "h"|"v"|"hv" }): number // one char per pixel; "." and " " skip; "#00000000" erases px(points: [x, y, color][]): number; line(x0, y0, x1, y1, color): number rect(r, color, o?: { fill? }): number; ellipse(r, color, o?: { fill? }): number; fill(x, y, color): number outline(color?, o?: { mode?: "selective"|"outside"|"inside"; rect? }): number // selective needs no colour shift(dx, dy, o?: { rect? }): number copy(from: { layer, frame?, sprite? } | { image: img.image }, o?: { rect?, x?, y?, flip? }): number // not the handle itself recolor(map: { "#from": "#to" }, o?: { rect? }): number; clear(r?): number bounds(): Rect | null // [x, y, w, h] of the non-transparent pixels; null when empty read(o?: { rect?; palette? }): { palette, rows } } // same format as map; pass your palette to keep its keys Rect = [x, y, w, h] | "selection". Colours are "#rgb", "#rrggbb" or "#rrggbbaa". Drawing methods return pixels changed.

Rules:

  • Edits go to a draft. When the program returns, each touched sprite commits as ONE undo step ("MCP: program").

  • A throw or timeout commits nothing; the result lists the discarded cels. await s.commit("label") is a checkpoint that survives a later throw.

  • Pixel loops belong in methods: map/rect/fill/shift run natively; a JS loop per pixel is slow.

  • Return only what you need (counts, a few rows), never whole sprites or handles.

  • view() writes a PNG and returns its path; open the file to look. Use critique: true to judge colour, values and silhouette in one image.

  • The result's warnings name each drawing call that dropped pixels outside the canvas; move the art or s.resize().

  • The result's commit list reports merged and lost: if the artist drew on the same cels meanwhile, both edits are kept and the artist wins where you overlap.

Example: const s = await sprite({ new: [32, 32] }) const P = { k: "#1a1c2c", ...ramp("#b13e53", "rst") } const c = s.cel("Layer 1") c.ellipse([8, 8, 16, 16], P.s, { fill: true }) c.map(P, ["..tt", ".tsst"], { x: 12, y: 10 }) c.outline() return await s.view({ critique: true })

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "execute"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesJavaScript program body; its return value becomes `value`.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so thoroughly: edits go to a draft, each sprite commits as one undo step, a throw or timeout discards all cels, explicit commit survives a throw, warnings name off-canvas drawing calls, and merge/lost semantics describe concurrent artist edits (artist wins). This is exactly the non-obvious behavior an agent needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded and logically sectioned (globals, objects, rules, example), but it is an entire API reference embedded in a description. Portions, particularly the detailed Sprite/Cel method signatures, could be delegated to the built-in help(topic) mechanism without losing correctness.

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?

For a single-string code-execution tool with no annotations and no output schema, the description supplies everything needed to call it correctly: execution model, coordinate conventions, atomicity/rollback, conflict handling, and how to inspect results via view(). Nothing material is missing.

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?

Schema coverage is 100% and the single `code` parameter is already documented, but the description goes far beyond by enumerating the runtime globals, object model, and return-value contract ('its return value becomes `value`') that the schema cannot express. That is genuine added meaning rather than restatement.

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?

Opens with a specific verb+resource+target: 'Draw pixel art live in the user's Aseprite by running a JavaScript program', and immediately states coordinate/frame conventions. An agent knows exactly what this tool does without opening the schema.

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

Usage Guidelines4/5

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

No siblings exist, but the description gives clear in-tool guidance on which primitives to use when (native map/rect/fill/shift vs JS pixel loops, view() to inspect, commit() to checkpoint before risky work, help(topic) for further topics). It lacks explicit when-not-to-use framing, but nothing comparable exists.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools