ahpixeleditor
by HsiaoJ0629
README.md
# ahpixeleditor
A browser pixel-art editor that Claude draws on live through [MCP](https://modelcontextprotocol.io).
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](https://www.aseprite.org/). 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.
## 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
```sh
claude mcp add ahpixeleditor -- npx -y ahpixeleditor
```
On native Windows (not WSL), `npx` must be started through `cmd`:
```sh
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:
```json
{
"mcpServers": {
"ahpixeleditor": {
"command": "npx",
"args": ["-y", "ahpixeleditor"]
}
}
}
```
On Windows, use `"command": "cmd"` and `"args": ["/c", "npx", "-y", "ahpixeleditor"]`.
### From a clone of this repo
```sh
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`.
## 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, `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 `export_png` to keep a result.
## 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

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.
The image-to-grid step is not built in yet; an import tool is planned
([ROADMAP.md](https://github.com/HsiaoJ0629/ahpixeleditor/blob/main/ROADMAP.md), "Import image → pixel art").
## 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)` | Layers |
| `add_frame(duration?, copy?)`, `select_frame(index)` | Frames |
| `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 |
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
```sh
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](https://github.com/HsiaoJ0629/ahpixeleditor/blob/main/docs/design.md). Plan: [ROADMAP.md](https://github.com/HsiaoJ0629/ahpixeleditor/blob/main/ROADMAP.md).
Set `AHPIXELEDITOR_PORT` to run the server on another port.
## Licence
[MIT](https://github.com/HsiaoJ0629/ahpixeleditor/blob/main/LICENSE) © 2026 HsiaoJ0629. Third-party notices: [THIRD_PARTY_NOTICES.md](https://github.com/HsiaoJ0629/ahpixeleditor/blob/main/THIRD_PARTY_NOTICES.md).
This server cannot be deployed
Maintenance
ActivityNo data
ResponsivenessOutdated data