pixel-composer-mcp
# pixel-composer-mcp
MCP server that lets an agent drive [Pixel Composer](https://github.com/Ttanasart-pt/Pixel-Composer)
(Steam build, Windows): open a `.pxc`, read its node graph, change input values, render every Export node.
## How it works
- Talks to the app's built-in **Remote Terminal** addon (WebSocket, `127.0.0.1:22400`). Each command
goes through the in-app console, which can call any GML function by name (`load_file_path`, `exportAll`, …).
- On every server start, `Addons/__init.json` is checked and `"Remote Terminal"` is appended if missing
(other enabled addons are kept). The first start enables it; later starts only check.
- If the port is already open (you started Pixel Composer yourself), the server **attaches** to it.
Otherwise it **launches** the app with `SteamAppId=2299510` (Steam builds abort without it) and reads its stdout.
If the app is running without the port (started before the addon was enabled), restart it.
- A Pixel Composer window appears while working. `--headless` is not used: in 1.22.x it loads a stub theme
missing keys that every Surface input needs, so almost no real project loads.
## Tools
| tool | what it does |
|---|---|
| `open_project(path)` | load a `.pxc` (launches the app if needed) |
| `inspect_project(path?)` | nodes, types, stored input values by index, connections (reads the file) |
| `set_input(node, index, value, path?, reload=True, absolute=False)` | edit a static input value in the file and reload it (replaces keyframes; `absolute` = pixels instead of 0..1) |
| `set_keyframes(node, index, keys, path?, reload=True, absolute=False)` | animate an input with linear keyframes `[[frame, value], ...]` |
| `add_node(node_type, x, y, file?)` | create a node (e.g. `Node_Particle`) in the open project via the app, save, return its id; file-reading nodes (`Node_ASE_File_Read`, `Node_Image`, …) take `file` |
| `connect(src, out_index, dst, in_index)` / `disconnect(dst, in_index)` | wire / unwire nodes in the file, then reload |
| `save()` | save the app's open project back to the `.pxc` |
| `describe_node(node_type)` | input/output names by index, read from a Pixel Composer source clone (`PXC_SOURCE`) |
| `check_sheet(path, style, frame_w?, frame_h?, ...)` | pass/fail a sprite sheet or image: hard alpha, colour count, stray colours, pixel grid (`pixel_scale`); effect rules (frames, ground, peak, edges) when given; writes a 2x contact preview |
| `export(timeout=180)` | run every Export node, wait until outputs stop changing, return file paths |
| `run_command(command)` | raw console command, e.g. `set <global> <value>` or `<gml_function> arg1 arg2` |
| `status()` / `close()` | mode, project, log tail / quit the app (only if this server launched it) |
Limits: input names are not stored in `.pxc`, so inputs are addressed by index. The output file
extension comes from the Export node's format setting (asking for `x.png` can produce `x.gif`).
Image sequences (Export input 3 = 1) need `%f` in the name template (input 2, e.g. `%d%n_%f`),
otherwise every frame overwrites the same file.
Paths with spaces are loaded from a copy in `%LOCALAPPDATA%\PixelComposer\mcp_work\` because the
console splits arguments on spaces. In attach mode there is no app log, so `export` detects
completion by watching the Export folders.
## Setup
```json
{
"mcpServers": {
"pixel-composer": {
"command": "uv",
"args": ["run", "--directory", "D:/MCPS/pixel-composer-mcp", "pixel-composer-mcp"]
}
}
}
```
Environment overrides: `PXC_DIR` (install folder), `PXC_DATA_DIR` (default `%LOCALAPPDATA%\PixelComposer`),
`PXC_TERMINAL_PORT` (default `22400`), `PXC_SOURCE` (clone of the Pixel Composer repo, for `describe_node`;
it tracks the latest source, so trust a saved `.pxc`'s defaults if an index looks off).
File-editing tools save the app first when the edited file is the open project, so unsaved in-app changes survive.
With `reload=False` the edit waits in the file; the next save, export or reloading edit loads it into the app first.
## Build scripts
For graphs with many nodes and keyframes, a Python build script is easier to iterate on and rebuild than
tool calls. `pixel_composer_mcp.graph` has the helpers (`new_project`, `Graph`, `emitter`, `switch`,
`curve`, `gradient`, `color`); `examples/elemental-rise` shows complete scripts. Run one from anywhere:
```
uv run --python 3.13 --with git+https://github.com/3Hoo/pixel-composer-mcp python build.py
```
## Agent skill
`skills/pixel-composer` is an agent skill for working with this server: how to interview the user
before building, a map of which Pixel Composer nodes do what (and which were verified through this
server), known pitfalls, and per-task notes for effects, item icons, tilesets and character rigging.
Install it by copying or linking the folder into your agent's skills directory:
```
# Claude Code (PowerShell)
New-Item -ItemType Junction -Path "$HOME\.claude\skills\pixel-composer" -Target "<repo>\skills\pixel-composer"
```
Other agents: the same folder under their skills directory (e.g. `~/.pi/agent/skills`).
## Security
Remote Terminal has no authentication and executes arbitrary app functions. It listens on all interfaces
(`::`), so keep port 22400 blocked from the network by the firewall. It stays enabled for normal app launches
too; turn it off in Pixel Composer's addon panel if you stop using this server.
## Tests
```
uv run pytest
```
TDQS
Scored across 7 tools
Most tools have clearly distinct purposes: open_project launches the app, inspect_project reads the file, set_input mutates a node value, export runs export nodes, status reports connection, close quits. The only overlapping pair is set_input vs run_command, since a raw console command could also modify values, but the descriptions clarify that set_input targets node inputs specifically.
Most names follow a verb_noun pattern (open_project, inspect_project, set_input, run_command), with minor deviations where export, status, and close are bare verbs/nouns. The convention is still predictable and readable throughout.
Seven tools is well-scoped for a Pixel Composer control server, covering lifecycle (open/close/status), inspection, mutation, and export without padding. Each tool earns its place.
Lifecycle, inspection, mutation, and export are all covered, and run_command provides an escape hatch for anything missing (node creation, connections, GML calls). Some first-class operations like creating nodes or editing connections are absent, but the console fallback mitigates this.