Aseprite Studio MCP
# Aseprite Studio MCP
**English** | [Bahasa Indonesia](./README.id.md)
A dual-mode (**Live GUI Bridge** + **Safe Staged CLI**) [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that lets AI assistants draw, animate, inspect, and export pixel art in **Aseprite** — either **live on your canvas in real time** or **safely headless** with automatic undo history, conflict detection, and backups.

> *The 8-layer, 12-frame Knight (`idle`, `walk`, `attack`) above was created and exported entirely through `aseprite-studio-mcp` — see [`examples/knight/`](./examples/knight/).*
---
## Why Aseprite Studio MCP?
Most Aseprite MCP servers force you to pick between **live editing** (requires Aseprite open) or **CLI scripts** (blind edits with no undo safety). **Aseprite Studio MCP gives you both** in a single server powered by one shared Lua engine (`lua/ops.lua`):
| Feature | Live Bridge Mode (Aseprite Open) | Staged CLI Mode (Headless Fallback) |
| :--- | :--- | :--- |
| **How it runs** | WebSocket extension inside Aseprite GUI (`~1–20 ms`) | Headless `aseprite --batch` on an isolated copy |
| **See edits live?** | Yes — watch every brushstroke appear on canvas | Inline PNG preview returned in chat |
| **Undo / Redo** | Native Aseprite `Ctrl+Z` / `Ctrl+Y` (`app.transaction`) | Multi-step snapshot journal (`undo_redo`) |
| **File safety** | Automatic pre-save disk backup + rollback | Original file untouched until `commit_changes` + disk conflict guard + backup/rollback |
| **Target active tab?** | Yes (`@active`, `@index:1`, `@name:Sprite-0001`) | Works on any `.aseprite` path on disk |
By default (`ASEPRITE_MCP_MODE=auto`), the server **automatically switches to Live Mode** the moment Aseprite connects, and **falls back to Staged CLI Mode** when Aseprite is closed.
---
## Quick Start (5 Minutes)
### Prerequisites
- **Node.js 20+**
- **Aseprite 1.3+** (built-in Lua `WebSocket` & `json` support)
### 1. Clone & Build
```bash
git clone https://github.com/Irmiyaa/aseprite-studio-mcp.git
cd aseprite-studio-mcp
npm install
npm run build
```
> **Windows PowerShell note:** If `npm` is blocked by execution policy, use `npm.cmd` (e.g., `npm.cmd install` and `npm.cmd run build`).
### 2. Install the Aseprite Live Bridge Extension *(Optional — enables Real-Time Live Mode)*
```bash
npm run install:extension
```
This automatically copies the extension into your Aseprite user extensions folder and also creates a standalone package at `dist/aseprite-studio-bridge.aseprite-extension`.
Then in **Aseprite**:
1. Restart Aseprite.
2. Open **File → Scripts → Aseprite Studio MCP: Live Bridge Panel...** (or click **Live Bridge Connected** to toggle).
3. On first connection, Aseprite asks for script permission — click **"Give full trust to this script"** so it auto-connects on every future launch.
*(You can skip Step 2 if you only want headless Staged CLI Mode.)*
### 3. Add to Your MCP Client
Add the entry from [`mcp-config.example.json`](./mcp-config.example.json) to your MCP client configuration (**Antigravity**, **Claude Desktop**, **Cursor**, **Windsurf**, **VS Code**, etc.):
```json
{
"mcpServers": {
"aseprite-studio": {
"command": "node",
"args": [
"/absolute/path/to/aseprite-studio-mcp/dist/index.js"
],
"env": {
"ASEPRITE_PATH": "/path/to/aseprite",
"ASEPRITE_MCP_MODE": "auto",
"ASEPRITE_MCP_WS_PORT": "49210"
}
}
}
}
```
> **Tip:** Replace `/absolute/path/to/aseprite-studio-mcp/dist/index.js` with your actual cloned path. `ASEPRITE_PATH` is optional if Aseprite is installed in a standard location (Program Files, Steam, `/Applications/Aseprite.app`, or in `PATH`).
---
## Example Prompts to Try
Once connected, just ask your AI assistant in plain language:
- *"Check `aseprite_status` to confirm whether Live Bridge is connected."*
- *"Create a 32x32 RPG slime sprite with PICO-8 palette, 4-frame bounce animation, dark outline, and show me a preview."*
- *"Draw a glowing sword on a new layer in my `@active` Aseprite tab."*
- *"Export `knight.aseprite` as a horizontal PNG spritesheet with JSON metadata and separate GIFs for each tag."*
- *"Undo the last change and restore the previous backup."*
---
## All 33 MCP Tools (83 Lua Operations)
Tools are intentionally grouped by domain using an `action` parameter to keep LLM token usage low and tool selection accurate, while exposing **83 shared operations** across both Staged CLI and Live GUI modes (plus built-in MCP workflow `instructions`).
| Category | Tools | What They Do |
| :--- | :--- | :--- |
| **Live Bridge & Status** | `aseprite_live`, `aseprite_status` | Switch mode (`auto`/`live`/`staged`), check connection & latency (`ping`), list/open/activate/save/close open tabs in Aseprite GUI |
| **Safety, Undo & Batch** | `commit_changes`, `discard_changes`, `undo_redo`, `manage_backups`, `batch_ops` | Atomic multi-op batches, staged commit with conflict check (or live save with backup), undo/redo (snapshot journal or native `Ctrl+Z`), pre-save backup listing & rollback |
| **Sprite & Inspection** | `create_sprite`, `inspect_sprite`, `render_preview`, `get_pixels`, `transform_sprite` | Create sprites with presets, full metadata inspection, inline PNG previews (zoom, **`region` crop**, grid, onion skin, single layer), ASCII pixel readout, resize/crop/expand/flip/rotate/color-mode |
| **Layers & Cels** | `manage_layer`, `manage_cel` | Add layers/groups, rename, opacity, blend mode, visibility, lock, reorder, duplicate, merge down, flatten, clear/move/copy cels |
| **Animation** | `manage_frames`, `manage_tags`, `animate_cels` | Frame add/delete/durations, animation tags, plus **propagate cels, duplicate/reverse frame ranges, batch offset, eased position/opacity tweening, sinusoidal/triangle oscillate, ensure missing cels** |
| **Drawing & Text** | `draw_pattern`, `draw_pixels`, `draw_shapes`, `draw_text`, `fill_area`, `replace_color`, `add_outline`, `edit_region` | ASCII grids, exact pixels, line/rect/ellipse/**filled polygon/isometric 3D box**, **built-in 5×7 pixel bitmap text** (with shadow/outline & measure), flood fill, color swap, outlines, **move/copy/erase region & erase color** |
| **Effects & Shading** | `apply_effect` | **HSL adjustment, brightness/contrast, invert, ordered Bayer dithering (`checker`, `2x2`, `4x4`, `8x8`) gradients & patterns, smooth/banded gradients (`maskToSolid`), and 3×3 convolution filters** |
| **Palettes** | `manage_palette` | Inspect/edit palettes, retro presets (`pico-8`, `gameboy`, `sweetie-16`, `db16`, `db32`, `endesga-32`, `grayscale-8`), **hue-shifted `generate_ramp`, `extract` from pixels, and `quantize` with optional Bayer dithering** |
| **Visual Analysis & QA** | `analyze_sprite` | **`compare_frames` diff, per-frame `get_bounds`, `lint` (lone stray pixels, detached islands, empty cels), `color_stats` (histogram + near-duplicate drift), `audit_animation`** |
| **Slices & Tilemaps** | `manage_slices`, `manage_tilemap` | Named slices with **9-patch `center` & `pivot`**, plus **tilemap layers, tileset slot creation, tile drawing, grid placement with `flipX`/`flipY`/`flipD`, tile queries** |
| **Export & Import** | `export_asset`, `import_asset` | Export PNG, GIF (full/tag), spritesheet (PNG+JSON), **separate per-layer PNGs (`format='layers'`)**; **import external images (PNG/GIF/BMP) or copy layers across `.aseprite` files** |
| **Custom Scripting** | `run_lua` | Run custom Aseprite Lua scripts safely inside a staged snapshot or live `app.transaction` |
### Special Live Mode Targets (`file` parameter)
When Live Bridge is connected, every tool accepts:
- A regular file path (e.g. `sprites/hero.aseprite`) — edits the already-open tab, or opens it automatically in Aseprite.
- `"@active"` — targets the currently active tab in Aseprite (even unsaved new sprites).
- `"@index:1"` — targets open tab `#1`.
- `"@name:Sprite-0001"` — targets an open tab by filename/title.
---
## Configuration (Environment Variables)
| Variable | Default | Description |
| :--- | :--- | :--- |
| `ASEPRITE_PATH` | Auto-detected | Path to the Aseprite executable |
| `ASEPRITE_MCP_MODE` | `auto` | `auto` (Live when connected, else Staged), `live`, or `staged` |
| `ASEPRITE_MCP_WS_ENABLED` | `true` *(unless `staged`)* | Enable/disable the local WebSocket Live Bridge server |
| `ASEPRITE_MCP_WS_HOST` | `127.0.0.1` | WebSocket server bind host |
| `ASEPRITE_MCP_WS_PORT` | `49210` | WebSocket server port (`0` for ephemeral OS port) |
| `ASEPRITE_MCP_WS_TOKEN` | *(empty)* | Optional shared auth token between Aseprite extension & server |
| `ASEPRITE_MCP_LIVE_TIMEOUT_MS` | `30000` | Timeout per Live Bridge RPC (ms) |
| `ASEPRITE_MCP_DATA_DIR` | `~/.aseprite-studio-mcp` | Storage for staged sessions, undo snapshots, and backups |
| `ASEPRITE_MCP_WORKDIR` | `process.cwd()` | Base directory for resolving relative paths |
| `ASEPRITE_MCP_ALLOWED_DIRS` | *(empty = unrestricted)* | Allowed workspace directories (`;` on Windows, `:` on macOS/Linux) |
| `ASEPRITE_MCP_AUTOCOMMIT` | `false` | Automatically save/commit after each mutation (still creates backups) |
| `ASEPRITE_MCP_HISTORY_LIMIT` | `50` | Max undo/redo snapshots kept per staged session |
| `ASEPRITE_MCP_BACKUP_LIMIT` | `20` | Max rollback backups kept per file |
| `ASEPRITE_MCP_TIMEOUT_MS` | `120000` | Timeout per headless CLI run (ms) |
---
## Troubleshooting
- **Live Bridge shows "Connecting..." in Aseprite:** Make sure your MCP client has started `aseprite-studio-mcp` and both use the same port (`49210` by default). Check `aseprite_status` in your AI client to verify `live.listening: true`.
- **Permission popup in Aseprite:** Click **"Give full trust to this script"** once so Aseprite allows WebSocket communication and temp PNG previews without interrupting future requests.
- **Uncommitted staged edits error when switching to Live:** Run `commit_changes` or `discard_changes` on that file first so your staged edits and live canvas never diverge silently.
---
## Running Tests
```bash
# Stage 1 E2E test suite (Staged CLI mode, 14 checks across 33 tools + schema audit)
npm run test:e2e
# Stage 2 E2E test suite (Real Aseprite extension.lua + WebSocket Live Bridge + HybridBackend)
npm run test:live
# Stage 3 E2E test suite (Effects, dithering, ramps, text, tweening, analysis, slices, tilemaps, import)
npm run test:stage3
# Run all 3 suites
npm run test:all
```
---
## Ringkasan Cepat (Bahasa Indonesia)
**Aseprite Studio MCP** memungkinkan AI menggambar, menganimasikan, mengecek, dan mengekspor pixel art di **Aseprite** dalam dua mode otomatis:
- **Mode Live Bridge:** Perubahan langsung tampil real-time di kanvas Aseprite GUI dengan native `Ctrl+Z`, target tab aktif (`@active`), dan backup otomatis sebelum simpan.
- **Mode Staged CLI:** Jika Aseprite tidak terbuka, server otomatis beralih ke mode headless yang aman (file asli tidak tersentuh sebelum `commit_changes`, lengkap dengan undo/redo, deteksi konflik disk, dan rollback backup).
👉 Baca panduan lengkap berbahasa Indonesia di **[README.id.md](./README.id.md)**.
---
## Contributing & License
Contributions are welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) before opening a pull request.
Licensed under the [MIT License](./LICENSE) © 2026 Fadhil Muzaffar.
TDQS
Scored across 33 tools
Most tools target a clearly distinct operation: drawing primitives (draw_pattern vs draw_pixels vs draw_shapes), region edits, effects, and per-resource managers (layer/cel/frame/tag/slice/tilemap) are well separated by their descriptions. A few boundaries blur: batch_ops vs run_lua both run arbitrary multi-step logic, edit_region's move/copy overlaps manage_cel, and commit_changes/discard_changes partially duplicate aseprite_live/aseprite_status save-close behavior.
The dominant convention is verb_noun (create_sprite, draw_shapes, manage_layer, export_asset, analyze_sprite) applied consistently across ~25 tools. Minor deviations exist: prefix-style aseprite_live/aseprite_status, the ambiguous verb_verb undo_redo, and noun-only batch_ops, but the overall pattern remains predictable.
33 tools is heavy, but the domain (a full pixel-art editor with modes, layers, cels, frames, tags, slices, tilemaps, palettes, export, and analysis) is genuinely broad and the tools are dense multi-operation bundles rather than one-op wrappers. Still, the surface is large enough that an agent must scan a lot of vocabulary to pick correctly.
The surface covers the full sprite lifecycle: create/inspect, draw/fill/replace/outline, transform, layers/cels/frames/tags/slices/tilemaps, palette management, import/export, preview rendering, quality analysis, backups, undo/redo, commit/discard, and a run_lua escape hatch for anything missing. No obvious dead ends remain for a pixel-art workflow.