ahpixeleditor

v0.4.0
ahpixeleditor Checked 2 days ago Published 2 days ago

A pixel-art editor that Claude draws on live through MCP, with a browser editor you can watch and edit in.

A browser pixel-art editor that Claude draws on live through MCP. You watch every AI stroke appear, undo any AI step on its own, and recolour or edit the result yourself in the same document. Inspired by Aseprite. Not affiliated with or endorsed by it, and it contains none of its code. No install step: the server runs from npm with npx.

Summary extracted from the README.

ahpixeleditor

A browser pixel-art editor that Claude draws on live through MCP. You watch every AI stroke appear, undo any AI step on its own, and recolour or edit the result yourself in the same document.

The editor showing a slime Claude drew on its own layer, with the AI steps in the history panel

Inspired by Aseprite. Not affiliated with or endorsed by it, and it contains none of its code.

Features

  • Indexed colour: changing a palette slot recolours every pixel that uses it.
  • Layers (visible / locked) and frames.
  • AI strokes play back pixel by pixel in the editor.
  • One shared undo history for you and the AI. Each AI tool call is one undo step.
  • "Revert last AI step" removes the AI's last change but keeps your edits on top of it.
  • While you draw a stroke, AI calls wait (up to 5 s) so the two never collide.
  • Animation: play frames at their own durations, onion skin, and export a sprite sheet PNG.
  • Save and Open the document as a .json file, from the editor or through the save / load tools.
  • Zoom in and out (up to 64×, less for big sprites so the canvas stays at most 4096 px) or fit to the window.
  • Change the canvas size (common sizes or custom; crop or extend at any of 9 anchors), undoable, in the editor or with resize_canvas.
  • Export an .aseprite file (layers, frames, palette) with Export .aseprite or the export_aseprite tool.
  • Rename (double-click the name, or ✎) and delete (🗑) layers, both undoable; or rename_layer / delete_layer.
  • Import pixel art… recreates a pixel-art image (PNG, JPG, or anything your browser opens) as a new sprite, with a preview: it finds the pixel grid (fractional scales such as 5.12× too), takes one colour per art pixel, clears a plain background and builds the palette. When the grid is found the result is exact; for smoothly resized images, photos or art bigger than 256 px it scales to fit and says the result is approximate. Claude has the same as import_pixel_art (PNG or JPEG).
  • When the import is not good enough, the pixel_art_from_image prompt has Claude recreate the image by hand in a style you describe (see Recreate an image in your own style).
  • Select an area (M) to limit the AI to it: its drawing only changes pixels inside the selection, and palette changes are refused until you clear it (Esc).

Requirements

  • Node.js 22.22 or newer
  • Claude Code (or another MCP client, e.g. Claude Desktop)

Connect it to Claude

No install step: the server runs from npm with npx.

Claude Code

claude mcp add ahpixeleditor -- npx -y ahpixeleditor

On native Windows (not WSL), npx must be started through cmd:

claude mcp add ahpixeleditor -- cmd /c npx -y ahpixeleditor

Claude Desktop

Add this to claude_desktop_config.json (Settings → Developer → Edit Config) and restart Claude Desktop:

{
  "mcpServers": {
    "ahpixeleditor": {
      "command": "npx",
      "args": ["-y", "ahpixeleditor"]
    }
  }
}

On Windows, use "command": "cmd" and "args": ["/c", "npx", "-y", "ahpixeleditor"].

From a clone of this repo

git clone https://github.com/HsiaoJ0629/ahpixeleditor.git
cd ahpixeleditor
npm install
npm run build

The repo ships a .mcp.json, so starting claude in the repo folder offers the ahpixeleditor server (built from source). Approve it when asked, or run /mcp.

The editor inside Claude Desktop

Claude Desktop can show the editor inside the conversation (an MCP App). Ask Claude to "open the pixel editor" (it calls the open_editor tool). What Claude draws appears there within about a second, and you can draw in it too. It talks to the server through Claude Desktop, not through the network. Claude Code does not show embedded apps; use the browser editor at http://localhost:7777 there. The browser editor keeps working next to the embedded one. Two differences in the embedded editor: AI calls do not wait while you draw a stroke (there is no lock), and the hidden tool it syncs through relies on Claude Desktop keeping it away from the model.

Use it

  1. Start a Claude session with the server connected. The server starts with it.
  2. Open http://localhost:7777 in your browser.
  3. Ask Claude to draw, for example:

    Create a 32×32 sprite with a 16-colour palette and draw a slime on its own layer. Check render_preview and fix mistakes.

Editor shortcuts: B pencil, E eraser, G fill, I picker, M select AI area, Esc clear it, Ctrl + + / - zoom (or Ctrl+wheel, or + / - alone), Ctrl+0 or 0 fit and centre, hold Space (or the middle mouse button) and drag, or use the wheel, to move the canvas anywhere, Ctrl+Z undo, Ctrl+Y or Ctrl+Shift+Z redo (Cmd on macOS).

Only one session can run at a time (it uses port 7777). The document lives in the server's memory and is lost when the Claude session ends; use Save (or the save tool) to keep it, and export_png for an image.

Examples

A slime, drawn from a prompt

The screenshot at the top. Claude got the prompt above, designed a 32×32 slime with a 16-colour palette on its own layer, checked render_preview, and fixed its own mistake: the first ground shadow was too dark and merged with the outline, so it lightened that palette slot and widened the shadow with two rect calls.

A ninja, recreated from a reference image

A pixel-art ninja reference image on the left, and the 88×123 sprite drawn through the MCP server on the right

Left: the reference image. Right: the sprite drawn through the MCP server. A small script measured the reference's pixel grid (about 5 image pixels per art pixel), took one colour per cell, made the white background transparent and reduced the colours to a 16-colour palette. The MCP tools then drew the result: create_sprite(88, 123, palette), add_layer("ninja"), and 11 draw_pixel_map calls of 12 rows each, so the editor played it back top to bottom and each band is one undo step.

To do the same with your own image, give Claude this prompt (replace the path):

Recreate this pixel-art image in ahpixeleditor as closely as possible: C:/path/to/reference.png

1. Write a small throwaway script outside this project (Python with Pillow is fine) that:
   - finds the image's pixel grid: how many image pixels make one art pixel;
   - takes one colour per grid cell (the most common colour in the cell, not the average);
   - makes the plain background transparent;
   - reduces the colours to a palette of at most 16 colours (more only if the art needs it);
   - prints the sprite size, the palette as #rrggbb, and the rows as a text grid with one
     character per palette index ("." for transparent).
2. Draw it with the ahpixeleditor tools: create_sprite(width, height, palette), add_layer with a
   name, then draw_pixel_map in bands of about 12 rows, top to bottom.
3. Check render_preview against the reference and fix any pixels that differ.

Since 0.3.0 the editor's Import pixel art… and the import_pixel_art tool do steps 1 and 2 for you.

Recreate an image in your own style

The server also ships a prompt, pixel_art_from_image, for when the import is not what you want: a photo, a drawing, or pixel art in a different style. In Claude Code type /mcp__ahpixeleditor__pixel_art_from_image; in Claude Desktop pick it from the server's prompts. Give it the image path and, optionally, a style such as "16-bit RPG sprite, 32x32, 16 colours, dark outline, no dithering". Claude tries the import first, and otherwise designs the sprite itself and draws it with the tools, then checks it with render_preview.

MCP tools

Tool What it does
create_sprite(width, height, palette?) New sprite (replaces the current one, clears history)
get_sprite_info() Size, palette, layers, frames, current layer/frame
set_palette(colors) / set_palette_color(index, color) Change the palette
draw_pixel_map(x, y, rows, legend) Draw a text grid; the main drawing tool
draw_pixels(points), line(...), rect(...), fill(x, y, index) Basic drawing
add_layer(name), select_layer(layer), rename_layer(layer, name), delete_layer(layer) Layers
add_frame(duration?, copy?), select_frame(index), set_frame_duration(index, duration) Frames
export_sprite_sheet(path, scale?) Save all frames side by side as one PNG
get_pixels(layer?, frame?) Read a layer back as a text grid
render_preview(scale?) PNG preview of the current frame
undo() Undo the newest step
export_png(path, scale?) Save the current frame as a PNG
resize_canvas(width, height, anchor?) Crop or extend the canvas; the art stays at the anchor (default center)
export_aseprite(path) Save layers, frames and palette as an .aseprite file (uncompressed; no tags or slices)
open_editor() Show the editor inside the conversation (Claude Desktop and other MCP Apps clients only)
import_pixel_art(path, maxColors?, removeBackground?, pixelSize?, name?) Recreate a pixel-art PNG or JPEG as a new sprite (replaces the sprite, clears history); approximate when no grid is found
save(path) / load(path) Save the document to a .json file / open one (load replaces the sprite and clears history)

The drawing tools also take optional layer (id or name) and frame; by default they draw on the current layer and frame. Palette index 0 is always transparent. Coordinates, frames and indices start at 0.

Development

npm test        # vitest, all packages
npm run build   # core, server, editor
  • packages/core: document model, commands, history, render (no UI or network code).
  • packages/server: MCP over stdio, plus HTTP and WebSocket on 127.0.0.1:7777.
  • packages/editor: Angular + <canvas> editor.

Design notes: docs/design.md. Set AHPIXELEDITOR_PORT to run the server on another port.

Licence

MIT © 2026 HsiaoJ0629. Third-party notices: THIRD_PARTY_NOTICES.md.