Skip to main content

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

Pyxel's bundled platformer example driven headlessly with right held and three scheduled jumps Frame 80 of the same run at scale 3, returned inline as image content

Both images come from one run call against Pyxel's bundled 10_platformer.py: 150 frames, right held from frame 0, jumps scheduled at frames 25, 70, and 110, a video snapshot, and an inline screen_image snapshot.

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.

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 >= 3.0.1 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, Pyxel and Cube type stub 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.

Pyxel Cube

Pyxel 3 adds software-rendered 3D through pyxel.cube. Use the same run tool, scheduled inputs, and screen snapshots to observe Cube programs. pyxel_info includes Cube examples such as cube/c01_hello_cube; pass an example's path to run so its bundled assets resolve correctly. Read its source through pyxel://examples/cube/c01_hello_cube.

stubs_path and cube_stubs_path point to the API type stubs installed with Pyxel. The Pyxel API reference and Cube API reference provide full descriptions. State snapshots can inspect explicit numeric paths such as scene.camera.transform.pos.x; whole Cube objects are returned as text representations. The asset readers continue to inspect image banks, tilemaps, and audio; they do not export a Cube scene or mesh.

When updating older projects, Pyxel 3 no longer accepts the old MML syntax or pre-2.0 resource files. See the current MML commands.

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 a top-level example bundled with the installed Pyxel package.
  • pyxel://examples/cube/{name} — source for a bundled Pyxel Cube example.

Discover examples with pyxel_info. Append its returned name to pyxel://examples/ to read the source, or pass its path to run.

Update

uvx caches packages. Force a refresh with:

uvx --refresh-package pyxel-mcp --refresh-package pyxel 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.

Metadata

Release files for pyxel-mcp 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyxel-mcp 1.4.0
File Size Uploaded Provenance Actions
pyxel_mcp-1.4.0.tar.gz 115.0 kB With provenance Details for pyxel_mcp-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyxel-mcp 1.4.0
File Interpreter ABI Platform Actions
pyxel_mcp-1.4.0-py3-none-any.whl Python 3 none any Details for pyxel_mcp-1.4.0-py3-none-any.whl

Total release size: 193.1 kB

Release files / pyxel_mcp-1.4.0.tar.gz

Download URL pyxel_mcp-1.4.0.tar.gz
Size 115.0 kB
Tags Source
SHA-256 checksum
How to use checksums
41c22c907033376d524debd4591026c48cf8b8320c1cbea94373e4867a3c1009
BLAKE2b-256 checksum
How to use checksums
913b42efb7a73132c411d356321a04c66a3c66d3e5be7cce62ba7b70f8f3f1e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / pyxel_mcp-1.4.0-py3-none-any.whl

Download URL pyxel_mcp-1.4.0-py3-none-any.whl
Size 78.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d7d65b3c1594c37a3f0e1485c1f5bb18c03e277f7bfd4c746a9da7e5bb30dd5
BLAKE2b-256 checksum
How to use checksums
5e03be7ad9269314f8e287d7bac7ebe68f50b77d81dca4f92760fe9708ac1d25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for pyxel-mcp 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyxel_mcp-1.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page