Skip to main content
Glama

pyxel-mcp

Let AI agents play, watch, and measure Pyxel games. pyxel-mcp is an MCP server that runs a Pyxel script headlessly, feeds it scheduled input, stops when a condition holds, and hands back the facts: screenshots, pixel grids, game state, assets, audio, and frame diffs.

PyPI Python Tests License MCP Registry

Why

An agent can write a Pyxel game in seconds, but it cannot open a window, press the arrow keys, or look at the screen. Editor-bound engines solve this with MCP servers that live inside the editor. Pyxel has no editor process to attach to, so pyxel-mcp drives the game itself:

  • Headless execution. Every call runs the script in a fresh subprocess with SDL dummy drivers and a frame budget. Set random_seed to seed Python's random module and Pyxel's random generator. Other randomness, timing, and external state can still affect the frames.

  • Input as data. Buttons, axes, and mouse position are scheduled per frame, so a playtest is a JSON document the agent can rerun and extend.

  • Stop on the event, not the clock. until="score >= 1" ends the run at the first frame where a game attribute holds, and "frame": "end" snapshots capture that moment.

  • Facts, not scores. Tools report pixels, values, and measurements. Deciding whether the game is good stays with the agent and the person asking for it.

  • See the frame in the result. inline: true returns a PNG as MCP image content, so the model looks at the screen without a second file read.

Related MCP server: Aseprite MCP

Install

Register the stdio server with your client:

claude mcp add --scope user pyxel -- uvx pyxel-mcp
codex mcp add pyxel -- uvx pyxel-mcp
gemini mcp add pyxel uvx pyxel-mcp

For Cursor (~/.cursor/mcp.json), a project-scoped Claude Code .mcp.json, or any other client that reads the common JSON format, add:

   {
     "mcpServers": {
       "pyxel": {
         "command": "uvx",
         "args": ["pyxel-mcp"]
       }
     }
   }

VS Code uses .vscode/mcp.json with a top-level servers key and "type": "stdio"; Codex CLI can also be configured in ~/.codex/config.toml as [mcp_servers.pyxel]. Run uvx pyxel-mcp install to print every variant.

Claude Code users can instead install the pyxel-skill plugin, which registers this server together with the skill that teaches agents how to use it:

claude plugin marketplace add kitao/pyxel-skill && claude plugin install pyxel@pyxel-skill

Restart the client after changing its configuration. The server writes this diagnostic to stderr:

[pyxel-mcp] starting - 8 tools

Python 3.11+ is required, and Pyxel >= 2.9.6 is installed as a dependency. Script tools execute local Python in subprocesses to isolate Pyxel state, but they do not sandbox untrusted code. See SECURITY.md.

How an agent uses it

flowchart LR
    W["Write or edit<br>game.py"] --> V["validate"]
    V --> R["run<br>inputs · until · snapshots"]
    R --> O{"Inspect facts<br>state · pixels · log"}
    O -- "defect" --> W
    O -- "looks right" --> A["read_image · read_tilemap<br>read_audio · diff_frames"]
    A --> D["Report evidence"]

The loop is deliberately small. The separate pyxel-skill project teaches agents when to use each tool and what counts as enough evidence; this package only supplies the observations.

Tools

Every script argument is a file path, not Python source. Relative asset paths inside the script resolve from the script's directory, as when running python game.py from that directory.

Tool

Returns

validate

Syntax errors and recognizable Pyxel code patterns, without executing.

run

Headless frames, scheduled input, logs, and state, screen_image, screen_grid, or video snapshots.

pyxel_info

Installed versions, paths, bundled examples, and resource URIs.

read_palette

Palette colors and image-bank indices in use.

read_image

Image-bank pixels and an optional PNG render.

read_tilemap

Tile coordinates, source bank, usage counts, bounds, and an optional render.

read_audio

A rendered sound or music WAV plus measurable audio data.

diff_frames

Pixel differences between two PNG files.

All tools declare input and output schemas. Every result includes ok and errors.

Script tools observe the first pyxel.run() call while its enclosing resources remain active. run drives the callbacks there; the asset readers inspect the pre-loop state. pyxel.quit() ends a run normally and preserves completed frames. Statements after pyxel.run() are not executed. Enclosing cleanup runs after observation, and cleanup failures are reported with phase: "script_exit". Stopping uses internal BaseException signals. Scripts or context-manager cleanup that suppress these signals are unsupported and may execute post-run code.

Captured PNGs can travel inside the result: set inline: true on a screen_image snapshot, or inline=true on read_image and read_tilemap, and the PNG is returned as MCP image content next to the structured data. A single inline frame may omit its output path; the file is then written under the system temp directory and its path is still reported, so diff_frames and later comparisons keep working. At most 12 images are embedded per call.

Example

Hold right, jump at frame 25, stop as soon as the score changes, and look at that frame:

{
  "script": "/absolute/path/game.py",
  "frames": 600,
  "random_seed": 7,
  "inputs": [
    {"frame": 0, "buttons": ["KEY_RIGHT"]},
    {"frame": 25, "buttons": ["KEY_RIGHT", "KEY_SPACE"]},
    {"frame": 26, "buttons": ["KEY_RIGHT"]}
  ],
  "until": "score >= 1",
  "snapshots": [
    {"kind": "state", "frame": "end", "attrs": ["score", "player.x"]},
    {"kind": "screen_image", "frame": "end", "scale": 3, "inline": true}
  ]
}

The result reports until_met, the reached frame_count, the requested state values, the PNG path, and the PNG itself as image content. Artifact paths you choose must be absolute. Read log even when ok is true, and inspect captured images directly when appearance matters.

Resources

  • pyxel://run-snapshots-schema — complete run.snapshots grammar, including "end", ranges, and inline.

  • pyxel://validation-patterns — categories reported by validate.

  • pyxel://palette/default — default palette table.

  • pyxel://examples/{name} — source for an example bundled with the installed Pyxel package; discover names with pyxel_info.

Update

uvx caches packages. Force a refresh with:

uvx --refresh-package pyxel-mcp pyxel-mcp install

Troubleshooting

  • If tools do not appear, look for the starting - 8 tools diagnostic and restart the client.

  • If run fails, inspect errors, exit_status, and log.

  • If a script cannot find an asset, check the path relative to the script file, not to the client's working directory.

  • If a validation category is unfamiliar, read pyxel://validation-patterns.

  • Pyxel — the retro game engine this server observes.

  • pyxel-skill — the Agent Skill that turns these tools into a build-and-verify workflow.

  • CHANGELOG.md — what changed in each release.

MCP Registry

mcp-name: io.github.kitao/pyxel-mcp

License

MIT — see LICENSE.

Available Tools

8 tools
diff_framesA
Read-onlyIdempotent

Compare two PNG frames pixel by pixel and return their changed region and ratio.

Inputs: frame_a (required), frame_b (required). Returns: ok, ratio, errors, region, +7 more

pyxel_infoA
Read-onlyIdempotent

Report installed versions, paths, examples, and Pyxel resource URIs.

Inputs: no named parameters. Returns: ok, errors, examples, resources, +4 more

read_audioA

Render one Pyxel sound or music slot to WAV and return measurable audio data. Notes describe tracker fields, not an MML or PCM transcription.

Inputs: script (required), target (required), output_path (required). Returns: ok, path, notes, errors, +5 more

read_imageA

Read palette-index pixels from a Pyxel image-bank region and optionally render it to PNG; inline=true returns the render as image content and makes render_path optional.

Inputs: image (required), script (required), h, w, +4 more. Returns: ok, errors, pixels, region, +4 more

read_paletteC

Read the active Pyxel palette and the palette indices used by image banks.

Inputs: script (required). Returns: ok, colors, errors, palette_size, +2 more

read_tilemapA

Read Pyxel tile coordinates, usage, bounds, source bank, and optional rendered output; inline=true returns the render as image content and makes render_path optional.

Inputs: script (required), tilemap (required), inline, render_path. Returns: ok, size, tiles, usage, +7 more

runA

Run a Pyxel script headlessly for a frame budget or until a condition holds, with scheduled input and state, screen, or video capture. screen_image snapshots with inline=true also return the PNG as image content, and a single inline frame may omit its output path.

Inputs: frames (required), script (required), until, inputs, +4 more. Returns: ok, log, errors, seeded, +5 more

validateA
Read-onlyIdempotent

Check Python syntax and report recognizable Pyxel code patterns.

Inputs: script (required). Returns: ok, errors, issues

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool maps to a distinct concern: environment info, script execution, audio rendering, frame comparison, and specific resource readers for images, palettes, and tilemaps. Even the read_* tools are cleanly separated by resource type, so there is no meaningful overlap between them.

    Naming Consistency4/5

    Most tools follow a clear action_resource pattern, especially read_image, read_palette, read_tilemap, and read_audio. The deviations are minor: pyxel_info is noun-ish and run is a bare verb, but both are still understandable and do not undermine the overall scheme.

    Tool Count5/5

    With 8 tools, the surface is tightly scoped to running Pyxel scripts and inspecting Pyxel resources and output. No tool feels redundant or out of place, and the count is well within the ideal range.

    Completeness4/5

    The server covers a coherent inspect-and-run workflow: validate scripts, execute them, capture frames, diff frames, and read images, palettes, tilemaps, and audio. The main gap is the lack of tools for creating or modifying Pyxel resources, which is a workaround if the server is intended as a read-only/testing interface.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers