Pyxel MCP

io.github.kitao由 GitHub 账号 kitao 发布v1.3.2更新于 Oct 25, 2026

MCP server for Pyxel, a retro game engine for Python

已验证STDIO仅桌面开发者工具媒体与设计

概览

AI 生成的概览

一个 MCP 服务器,可无界面运行 Pyxel 复古游戏脚本,注入按帧调度的输入,并返回截图、状态、素材、音频和帧差异。

可以做什么
校验 Pyxel 脚本的语法和可识别的代码模式而不执行,并报告已安装版本、路径、示例和资源 URI。在帧预算内或直到某个游戏属性条件成立时无界面运行脚本,支持按帧调度按键、轴和鼠标输入以及随机种子。在指定帧捕获状态值、屏幕图像、像素网格或视频,可选择以内联图像内容返回 PNG。读取调色板、图像库像素和瓦片地图数据,可选渲染为 PNG。将某个音效或音乐槽渲染为 WAV 并返回可测量的音频数据,以及逐像素比较两张 PNG 帧。
适用场景
适合助手编写或修改 Pyxel 游戏后需要实际试玩时:驱动输入、在分数变化等事件处停止,并检查屏幕、状态或素材。也适合核对精灵、瓦片地图和音频数据,或发现帧之间的视觉回归。
运行要求
通过 stdio 在本地运行,通常用 uvx pyxel-mcp 启动。需要 Python 3.11 及以上和 Pyxel 2.9.6 及以上(作为依赖安装)。脚本参数必须是绝对文件路径;未声明账号、密钥或环境变量。
安装前请注意
脚本工具会在子进程中执行本地 Python;这能隔离 Pyxel 状态但不是沙箱,只应运行可信脚本。运行会向你指定的路径写入产物文件,未指定路径的内联帧会写入系统临时目录。停止依赖内部信号,抑制这些信号的脚本可能执行运行后的代码。随机性、时序和外部状态仍可能影响帧。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Pyxel MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

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:

bash
claude mcp add --scope user pyxel -- uvx pyxel-mcp
bash
codex mcp add pyxel -- uvx pyxel-mcp
bash
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:

json
   {     "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:

bash
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:

text
[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

mermaid
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.

ToolReturns
validateSyntax errors and recognizable Pyxel code patterns, without executing.
runHeadless frames, scheduled input, logs, and state, screen_image, screen_grid, or video snapshots.
pyxel_infoInstalled versions, paths, bundled examples, and resource URIs.
read_palettePalette colors and image-bank indices in use.
read_imageImage-bank pixels and an optional PNG render.
read_tilemapTile coordinates, source bank, usage counts, bounds, and an optional render.
read_audioA rendered sound or music WAV plus measurable audio data.
diff_framesPixel 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:

json
{  "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:

bash
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.

Related

  • 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.

来源:README.md,提交 e1b6b74

工具

8

run

Run Pyxel script headlessly

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.

输入参数untilframes必填inputsscript必填timeoutsnapshotsrandom_seedstall_window_frames

validate

Validate Pyxel script

Check Python syntax and report recognizable Pyxel code patterns.

输入参数script必填

pyxel_info

Pyxel environment info

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

无需输入参数。

read_palette

Read Pyxel palette

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

输入参数script必填

read_image

Read image bank region

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.

输入参数hwxyimage必填inlinescript必填render_path

read_tilemap

Read tilemap

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.

输入参数inlinescript必填tilemap必填render_path

read_audio

Render audio to WAV

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

输入参数script必填target必填output_path必填

diff_frames

Diff two frames

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

输入参数frame_a必填frame_b必填

版本历史

3
  1. v1.3.2最新Oct 24, 2026
  2. v1.3.1Sep 22, 2026
  3. v1.3.0Sep 16, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分