Skip to content

z80mcp

A Z80 machine emulator exposed as an MCP 2.0 (protocol revision 2026-07-28) stdio server. It lets a coding agent operate emulated retro machines as native tools: read memory like a book, inspect and patch ROMs, load programs, drive keyboard and screen — deterministic, testable, no screen-scraping.

It was created so that agent-based development on retro targets (ZX81 BASIC, CP/M software) gets the same rigor as native development: exact memory inspection, exact screen decode, repeatable program runs. The primary machine is the ZX81; generic CP/M follows as the second v1 machine, with ZX80, ZX Spectrum and Jupiter Ace planned on the same machine-descriptor mechanism.

Features

  • Headless Z80 emulation with a frozen-frame interaction model: pause, step by display lines, inspect, patch, resume — reproducible runs.
  • MCP 2.0 stdio server (built on mcp-core), so any MCP host can use it.
  • Tools (v1):
  • machine_info, cpu_state — machine identity, registers, state
  • mem_read, mem_write — memory access incl. ROM unprotect
  • screen_read — screen content as UTF-8 text or PNG
  • key_inject, key_release — keyboard matrix control
  • load_program — load a .P image into RAM
  • pause, run, step — run control
  • cpm_dir, cpm_read_file, cpm_write_file — CP/M disk access
  • Machines v1: ZX81 (primary) and generic CP/M (reference behavior from RunCPM).
  • Plain C17, Unity-based test suite, ASan/UBSan clean.

Prerequisites

  • GNU make and a C compiler (cc); no external libraries — cJSON, the z80 emulation core and Unity are vendored in vendor/.
  • A sibling checkout of mcp-core at ../mcp-core — the Makefile builds its static library from there.

Usage

Build and test:

make            # builds the server binary
make test       # unit tests, ASan/UBSan clean

Register it with an MCP host (e.g. OpenClaw) as a stdio server:

./bin/z80mcp

Typical agent interaction — load a ZX81 program, run it, read the screen:

load_program {"image_b64": "..."}   # .P image into RAM
run {}                              # start execution (FAST tempo)
pause {}                            # freeze the frame
screen_read {"format": "text"}      # screen content as text

See SPEC.md for the interaction model, machine descriptors and the full tool contract.

License

MIT — see https://opensource.org/license/mit.

Contact

devel ät datenbrei.de

Download & Release Notes