Metadata-Version: 2.5
Name: amiberry-mcp-server
Version: 1.1.0
Summary: MCP server for controlling the Amiberry Amiga emulator from any MCP-compatible AI assistant
Project-URL: Homepage, https://github.com/BlitterStudio/amiberry-mcp-server
Project-URL: Repository, https://github.com/BlitterStudio/amiberry-mcp-server
Project-URL: Issues, https://github.com/BlitterStudio/amiberry-mcp-server/issues
Author: midwan
License-Expression: GPL-3.0-or-later
License-File: LICENSE
Keywords: ai,ai-assistant,amiberry,amiga,emulator,mcp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Emulators
Requires-Python: >=3.10
Requires-Dist: mcp<2,>=1.0.0
Provides-Extra: all
Requires-Dist: fastapi>=0.100.0; extra == 'all'
Requires-Dist: jeepney>=0.8.0; extra == 'all'
Requires-Dist: opentelemetry-api<1.46; extra == 'all'
Requires-Dist: pydantic>=2.0.0; extra == 'all'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'all'
Requires-Dist: pytest>=7.0.0; extra == 'all'
Requires-Dist: ruff>=0.1.0; extra == 'all'
Requires-Dist: uvicorn>=0.20.0; extra == 'all'
Provides-Extra: dbus
Requires-Dist: jeepney>=0.8.0; extra == 'dbus'
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: http
Requires-Dist: fastapi>=0.100.0; extra == 'http'
Requires-Dist: opentelemetry-api<1.46; extra == 'http'
Requires-Dist: pydantic>=2.0.0; extra == 'http'
Requires-Dist: uvicorn>=0.20.0; extra == 'http'
Description-Content-Type: text/markdown

# Amiberry MCP Server

An [MCP](https://modelcontextprotocol.io) (Model Context Protocol) server for
[Amiberry](https://github.com/BlitterStudio/amiberry), the Amiga emulator. It
lets an AI assistant list and edit configurations, launch games and disk
images, control a running emulation, and debug Amiga code.

The server speaks plain MCP over stdio, so any MCP client can use it: Claude
Desktop, Claude Code, Codex, Gemini (Antigravity), Cursor, Cline, Windsurf, and
others. The installer configures Claude Desktop, Claude Code, Codex, and
Gemini/Antigravity. For other clients, see [Other MCP clients](#other-mcp-clients).

A separate HTTP API exposes the same functions as REST endpoints for scripts,
home automation, and voice assistants.

## Features

**Files and launching**
- List and launch Amiberry configurations, or launch a Quickstart model
  (`A1000`, `A500`, `A500P`, `A600`, `A2000`, `A3000`, `A1200`, `A4000`,
  `CD32`, `CDTV`)
- Search disk images (ADF, HDF, DMS, LHA, ISO, CUE, CHD) and launch WHDLoad
  games from LHA archives
- Launch CD32 and CDTV images, and set up the disk swapper for multi-disk games
- Parse, edit, and create `.uae` configuration files from model templates
- Read metadata from `.uss` savestates and identify Kickstart ROMs by checksum

**Runtime control** (needs Amiberry built with IPC support)
- Pause, resume, reset, frame-advance, save and load states
- Swap floppies, CDs, and WHDLoad games in a running emulation
- Change chipset, CPU, memory, display, sound, and input settings at runtime
- Send keystrokes, text, and mouse input
- Take screenshots and click, drag, or hover at pixels picked from a screenshot
- Control one of several running Amiberry instances

**Debugging**
- Launch with logging, tail logs, and wait for a log pattern
- Detect crashes from the process exit status and log contents; kill and restart
- Read and write emulated memory, inspect CPU and custom chip registers,
  disassemble, single-step, and set breakpoints
- Use the GDB monitor command set (watchpoints, conditions, task and segment
  lists) without a GDB client
- Start Amiberry's GDB remote server from a launch argument or at run time,
  and attach `m68k-amigaos-gdb`, `m68k-elf-gdb`, or `gdb-multiarch`

## Requirements

- Python 3.10 or newer
- Amiberry:
  - **macOS**: `Amiberry.app` in `/Applications`
  - **Linux and FreeBSD**: `amiberry` on `PATH`
  - **Windows**: installed by the Amiberry installer or `Amiberry.exe` on
    `PATH`. The server finds the installer's copy through its registry
    entry (per-user under `%LOCALAPPDATA%\Programs\amiberry`, all-users
    under `%ProgramFiles%\amiberry`) without any PATH setup.
- An MCP client

The server runs on Linux, FreeBSD, macOS, and Windows, and raises
`RuntimeError` on any other platform.

Runtime control talks to Amiberry over IPC, which needs Amiberry built with
`USE_IPC_SOCKET=ON`. That is the default on all four platforms since Windows
gained the named-pipe transport after 8.4.1. On Windows the endpoint is the
named pipe `\\.\pipe\amiberry` (further instances use `\\.\pipe\amiberry_1`
through `\\.\pipe\amiberry_9`). Elsewhere it is the Unix socket
`$XDG_RUNTIME_DIR/amiberry.sock`, or `/tmp/amiberry.sock` when
`XDG_RUNTIME_DIR` is unset.

## Installation

### Recommended: uvx

[uv](https://docs.astral.sh/uv/) runs the server from PyPI without a checkout
or a virtual environment of your own:

```bash
uvx amiberry-mcp-server
```

This starts the MCP server on stdio, which only makes sense from an MCP
client, so you normally just put the command in the client's configuration
(see [Client configuration](#client-configuration)). For the HTTP API, which
needs the `http` extra:

```bash
uvx --from "amiberry-mcp-server[http]" amiberry-http
```

### pipx or pip

```bash
pipx install amiberry-mcp-server          # or "amiberry-mcp-server[http]"
```

Or into a virtual environment:

```bash
python3 -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate
pip install amiberry-mcp-server # or "amiberry-mcp-server[http]"
```

Either way you get three commands: `amiberry-mcp-server` and its older alias
`amiberry-mcp` start the MCP server, and `amiberry-http` starts the HTTP API.

### From a clone (development, and the installer)

```bash
git clone https://github.com/BlitterStudio/amiberry-mcp-server.git
cd amiberry-mcp-server
./scripts/install.sh            # macOS, Linux, FreeBSD
```

The installer:
1. Creates a virtual environment in `venv/`
2. Installs the package and its dependencies
3. Adds an `amiberry` entry to the Claude Desktop config, creating the file if
   needed
4. Adds the same entry for Claude Code, Codex, and Gemini (Antigravity) when it
   finds them installed

The installer is a shell script and does not run on Windows. Install manually
there, or on any platform where you prefer to:

```bash
python3 -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate
pip install -e .                # or ".[http]" to include the HTTP API
```

The installer's entries and the venv-python form in the client examples below
point at the clone. Other clients need the entry added by hand. See
[Other MCP clients](#other-mcp-clients).

### Updating

Releases are tagged (`v1.1.0` and later), published to PyPI, and listed on the
[releases page](https://github.com/BlitterStudio/amiberry-mcp-server/releases).

- **uvx**: `uvx amiberry-mcp-server` may reuse a copy of an older release that
  uv has cached. `uvx amiberry-mcp-server@latest` runs the newest release;
  use that form in the client's `args` to follow new releases.
- **uv tool install**, **pipx**, **pip**: `uv tool upgrade amiberry-mcp-server`,
  `pipx upgrade amiberry-mcp-server`, or
  `pip install --upgrade amiberry-mcp-server`.
- **Clone**: fetch and check out the release you want (or pull `main`), then
  reinstall into the same virtual environment so new dependency constraints
  apply:

  ```bash
  git fetch --tags
  git checkout v1.1.0                 # or: git checkout main && git pull
  pip install -e .                    # or ".[http]", matching the first install
  ```

Restart the MCP client afterwards so it starts the new server.

## Client configuration

Every stdio MCP client needs a command, arguments, and the stdio transport.
With uv:

| Field     | Value                                                    |
|-----------|----------------------------------------------------------|
| Command   | `uvx`                                                    |
| Args      | `["amiberry-mcp-server"]`                                |
| Transport | stdio                                                    |

If you installed with pipx or pip, use the full path of the
`amiberry-mcp-server` command as `command` and no args. For a clone:

| Field     | Value                                                    |
|-----------|----------------------------------------------------------|
| Command   | `/path/to/amiberry-mcp-server/venv/bin/python`           |
|           | Windows: `C:\path\to\amiberry-mcp-server\venv\Scripts\python.exe` |
| Args      | `["-m", "amiberry_mcp.server"]`                          |
| Transport | stdio                                                    |

GUI clients often start with a shorter `PATH` than your shell. If a client
cannot find `uvx`, give the full path in `command` (`which uvx`, or
`where uvx` on Windows).

### Claude Desktop

Edit the config file for your platform:

| Platform | Config file |
|----------|-------------|
| macOS    | `~/Library/Application Support/Claude/claude_desktop_config.json` |
| Linux    | `~/.config/Claude/claude_desktop_config.json` |
| Windows  | `%APPDATA%\Claude\claude_desktop_config.json` |

Add the server under `mcpServers`:

```json
{
  "mcpServers": {
    "amiberry": {
      "command": "uvx",
      "args": ["amiberry-mcp-server"]
    }
  }
}
```

For a clone, point at its virtual environment instead:

```json
{
  "mcpServers": {
    "amiberry": {
      "command": "/path/to/amiberry-mcp-server/venv/bin/python",
      "args": ["-m", "amiberry_mcp.server"]
    }
  }
}
```

On Windows, escape the backslashes in the JSON path
(`"C:\\path\\to\\amiberry-mcp-server\\venv\\Scripts\\python.exe"`).
Restart Claude Desktop afterwards.

### Other MCP clients

Add an entry with the same command and arguments:

| Client | Where |
|--------|-------|
| Claude Code | `claude mcp add amiberry -- uvx amiberry-mcp-server`, or `~/.claude.json` (set by the installer) |
| Codex | `~/.codex/config.toml`, as a `[mcp_servers.amiberry]` table with `command = "uvx"` and `args = ["amiberry-mcp-server"]` (set by the installer) |
| Gemini / Antigravity | `~/.gemini/antigravity/mcp_config.json` (set by the installer) |
| Cursor | `~/.cursor/mcp.json`, or `.cursor/mcp.json` inside a project |
| Cline, Continue, Windsurf | the client's MCP settings |
| Any other MCP client | run `uvx amiberry-mcp-server` (or `python -m amiberry_mcp.server`) over stdio |

### Checking the setup

Restart the client. The Amiberry tools should appear in its tool list (the
`/mcp` command, a tools icon, or a tool inspector, depending on the client).
Then ask something like:

- "What Amiberry configurations do I have?"
- "Show me my disk images"
- "Launch Amiberry with the A500 model"

## Amiberry directories

The server reads and writes the same directories Amiberry uses. It also
creates a `logs` directory under the content root for logs it captures.

| Platform | Content root | Settings (`amiberry.conf`, `amiberry.ini`) |
|----------|--------------|----------------------------------------------|
| macOS | `~/Documents/Amiberry` | `~/Library/Application Support/Amiberry` |
| Linux, FreeBSD | `~/Amiberry` | `$XDG_CONFIG_HOME/amiberry` (default `~/.config/amiberry`) |
| Windows | `%USERPROFILE%\Amiberry` | `%LOCALAPPDATA%\Amiberry`, falling back to `%APPDATA%\Amiberry` |

Inside the content root:

```
Amiberry/
├── Configurations/    # .uae config files
├── Floppies/          # .adf, .adz, .dms
├── HardDrives/        # .hdf, .hdz
├── LHA/               # .lha archives (WHDLoad games)
├── CDROMs/            # ISO, CUE, CHD
├── SaveStates/        # .uss savestates
├── Screenshots/
├── ROMs/              # Kickstart ROMs
└── logs/              # logs captured by this server
```

The settings directory holds settings only; it is not a second `.uae` config
tree.

Overrides:

- `AMIBERRY_BINARY` points the server at a specific Amiberry executable, on
  any platform, ahead of the automatic discovery (`PATH`, the Windows
  installer's registry entry, and the default Windows install directories).
  Handy for a portable copy or a development build.
- `AMIBERRY_HOME_DIR` replaces the content root, unless portable mode is on.
- An `amiberry.portable` file next to the Amiberry binary switches Amiberry to
  portable mode, and the server follows that root. macOS ignores the marker.
- `AMIBERRY_CONFIG_DIR` replaces the configurations directory on Linux and
  FreeBSD. Windows does not honor it: configurations are always in
  `<content root>\Configurations`.

ROM, savestate, and disk listings also search the pre-8.4 directory names that
Amiberry still migrates (`kickstarts`, `roms`, `savestates`, `floppies`,
`harddrives`, `lha`, and their case variants), so files copied from an older
tree still show up.

## MCP tools

The server exposes 154 tools. Tools whose names start with `runtime_` act on a
running emulation over IPC; the rest work on files and processes.

### Configurations and files

| Tool | Description |
|------|-------------|
| `list_configs` | List configuration files |
| `get_config_content` | Show the contents of a config file |
| `parse_config` | Parse a `.uae` file into structured data |
| `modify_config` | Change options in a config file |
| `create_config` | Create a config from a model template |
| `list_disk_images` | Search disk images (ADF, HDF, DMS, LHA) |
| `list_cd_images` | List CD images |
| `list_savestates` | List savestate files |
| `inspect_savestate` | Read metadata from a `.uss` savestate |
| `list_roms` | List ROMs with identification |
| `identify_rom` | Identify a ROM by checksum |
| `get_amiberry_version` | Show the installed Amiberry version |
| `get_platform_info` | Show platform and path information |

### Launching

| Tool | Description |
|------|-------------|
| `launch_amiberry` | Launch with a config, model, disk, or LHA file; optional `gdb_port` starts the GDB server |
| `launch_with_logging` | Launch with `--log` and capture the output to a file; accepts `gdb_port` |
| `launch_and_wait_for_ipc` | Launch and wait until the IPC endpoint is ready; accepts `gdb_port` |
| `launch_whdload` | Search for and launch a WHDLoad game |
| `launch_cd` | Launch a CD image (ISO, CUE, CHD) |
| `set_disk_swapper` | Set up the disk swapper for a multi-disk game |

### Processes, logs, and crashes

| Tool | Description |
|------|-------------|
| `check_process_alive` | Check whether Amiberry is running (PID, exit code, signal) |
| `get_process_info` | Process details with crash detection |
| `kill_amiberry` | Force-kill a running or hung Amiberry |
| `wait_for_exit` | Wait for the process to exit, with a timeout |
| `restart_amiberry` | Kill and relaunch with the same command |
| `health_check` | Check process, IPC, emulation status, and FPS in one call |
| `list_logs` | List captured log files |
| `get_log_content` | Read a captured log file |
| `tail_log` | Return log lines added since the last read |
| `wait_for_log_pattern` | Wait for a regex to appear in the log |
| `get_crash_info` | Detect a crash from the process state and log contents |

### Runtime: emulation and state

| Tool | Description |
|------|-------------|
| `get_runtime_status` | Get emulation status |
| `pause_emulation` | Pause emulation |
| `resume_emulation` | Resume emulation |
| `reset_emulation` | Soft or hard reset |
| `runtime_frame_advance` | Advance N frames while paused |
| `runtime_quit` | Ask Amiberry to quit over IPC (not a process kill) |
| `runtime_save_state` | Save state while running |
| `runtime_load_state` | Load a savestate |
| `runtime_quicksave` | Quick save to slot 0-9 |
| `runtime_quickload` | Quick load from slot 0-9 |
| `runtime_screenshot` | Save a screenshot to a file |
| `runtime_get_config` | Get a config option value |
| `runtime_set_config` | Set a config option |
| `runtime_load_config` | Load a `.uae` file into the running emulation |
| `runtime_list_configs` | List config files known to the running emulator |
| `runtime_get_led_status` | Get LED states (power, floppy, HD, CD) |
| `runtime_get_fps` | Get frame rate and idle percentage |

### Runtime: media

| Tool | Description |
|------|-------------|
| `runtime_insert_floppy` | Insert a floppy image into a drive |
| `runtime_eject_floppy` | Eject a floppy |
| `runtime_list_floppies` | List floppy drives and their contents |
| `runtime_disk_swap` | Insert a disk from the swapper list into a drive |
| `runtime_query_disk_swap` | Show which swapper slot is in a drive (`-1` if none) |
| `runtime_set_floppy_speed` | Set floppy speed (0=turbo, 100=1x, 200=2x, 400=4x, 800=8x) |
| `runtime_get_floppy_speed` | Get floppy speed |
| `runtime_disk_write_protect` | Set write protection for a drive |
| `runtime_get_disk_write_protect` | Get write protection for a drive |
| `runtime_insert_cd` | Insert a CD image |
| `runtime_eject_cd` | Eject the CD |
| `runtime_list_harddrives` | List mounted hard drives and directories |
| `runtime_insert_whdload` | Load a WHDLoad game (LHA archive or directory) |
| `runtime_eject_whdload` | Eject the loaded WHDLoad game |
| `runtime_get_whdload` | Show the loaded WHDLoad game |

### Runtime: hardware

| Tool | Description |
|------|-------------|
| `runtime_set_chipset` | Set chipset (OCS, ECS_AGNUS, ECS_DENISE, ECS, AGA) |
| `runtime_get_chipset` | Get chipset |
| `runtime_set_cpu_model` | Set CPU model (68000, 68010, 68020, 68030, 68040, 68060) |
| `runtime_get_cpu_model` | Get CPU model |
| `runtime_set_cpu_speed` | Set CPU speed (-1=max, 0=cycle-exact, >0=percent) |
| `runtime_get_cpu_speed` | Get CPU speed |
| `runtime_get_memory_config` | Get memory sizes (chip, fast, bogo, Z3, RTG) |
| `runtime_set_chip_mem` | Set Chip RAM (256, 512, 1024, 2048, 4096, 8192 KB) |
| `runtime_set_fast_mem` | Set Fast RAM (0, 1024, 2048, 4096, 8192 KB) |
| `runtime_set_slow_mem` | Set Slow (Bogo) RAM (0, 256, 512, 1024, 1792 KB) |
| `runtime_set_z3_mem` | Set Zorro III RAM (0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 MB) |

### Runtime: display and sound

| Tool | Description |
|------|-------------|
| `runtime_toggle_fullscreen` | Toggle fullscreen and windowed mode |
| `runtime_set_display_mode` | Set display mode (0=window, 1=fullscreen, 2=fullwindow) |
| `runtime_get_display_mode` | Get display mode |
| `runtime_set_window_size` | Set window size (width x height) |
| `runtime_get_window_size` | Get window size |
| `runtime_set_scaling` | Set scaling (-1=auto, 0=nearest, 1=linear, 2=integer) |
| `runtime_get_scaling` | Get scaling mode |
| `runtime_set_line_mode` | Set line mode (single, double, scanlines) |
| `runtime_get_line_mode` | Get line mode |
| `runtime_set_resolution` | Set resolution (lores, hires, superhires) |
| `runtime_get_resolution` | Get resolution |
| `runtime_set_autocrop` | Turn automatic cropping on or off |
| `runtime_get_autocrop` | Get autocrop state |
| `runtime_set_ntsc` | Set video mode (0=PAL, 1=NTSC) |
| `runtime_get_ntsc` | Get video mode |
| `runtime_toggle_rtg` | Switch between RTG and chipset display |
| `runtime_toggle_status_line` | Cycle the status line (off, chipset, RTG, both) |
| `runtime_set_warp` | Turn warp mode on or off |
| `runtime_get_warp` | Get warp mode |
| `runtime_set_volume` | Set master volume (0-100) |
| `runtime_get_volume` | Get volume |
| `runtime_mute` | Mute audio |
| `runtime_unmute` | Unmute audio |
| `runtime_set_sound_mode` | Set sound mode (0=off, 1=normal, 2=stereo, 3=best) |
| `runtime_get_sound_mode` | Get sound mode |

### Runtime: input

| Tool | Description |
|------|-------------|
| `runtime_send_key` | Press, release, or tap a key by name (`space`, `return`, `f1`) or scancode |
| `runtime_send_text` | Type a string through raw keys, using the US keymap or the one given in `keymap` ([details](#keyboard-layouts-and-pasting)) |
| `runtime_paste_text` | Paste text through the guest clipboard with Right Amiga+V ([requirements](#keyboard-layouts-and-pasting)) |
| `runtime_send_mouse` | Send mouse movement and button presses |
| `runtime_set_mouse_speed` | Set mouse sensitivity (10-200) |
| `runtime_get_mouse_speed` | Get mouse sensitivity |
| `runtime_toggle_mouse_grab` | Toggle mouse capture |
| `runtime_set_joyport_mode` | Set port mode (0=default, 2=mouse, 3=joystick, 7=CD32 pad) |
| `runtime_get_joyport_mode` | Get port mode |
| `runtime_set_autofire` | Set autofire (0=off, 1=normal, 2=toggle, 3=always, 4=toggle_noaf) |
| `runtime_get_autofire` | Get autofire mode for a port |

### Runtime: screenshot-driven GUI automation

| Tool | Description |
|------|-------------|
| `runtime_screenshot_view` | Return the screenshot image plus capture metadata for GUI actions |
| `runtime_gui_move` | Move or hover at a pixel in that screenshot |
| `runtime_gui_click` | Click or double-click a mouse button at a pixel |
| `runtime_gui_drag` | Drag with a mouse button between two pixels |

See [Screenshot-driven GUI automation](#screenshot-driven-gui-automation).

### Runtime: debugging

| Tool | Description |
|------|-------------|
| `runtime_debug_activate` | Enter the built-in debugger |
| `runtime_debug_deactivate` | Leave the debugger and resume emulation |
| `runtime_debug_status` | Get debugger status |
| `runtime_debug_step` | Single-step CPU instructions |
| `runtime_debug_step_over` | Step over subroutine calls (JSR, BSR) |
| `runtime_debug_continue` | Run until the next breakpoint |
| `runtime_get_cpu_regs` | Get CPU registers (D0-D7, A0-A7, PC, SR, USP, ISP) |
| `runtime_get_custom_regs` | Get custom chip registers (DMACON, INTENA, INTREQ, and others) |
| `runtime_disassemble` | Disassemble at an address |
| `runtime_set_breakpoint` | Set a breakpoint. `slot` (0-19) is optional; without it the first free slot is used |
| `runtime_clear_breakpoint` | Clear one breakpoint or all of them |
| `runtime_list_breakpoints` | List breakpoints |
| `runtime_read_memory` | Read 1, 2, or 4 bytes of emulated memory |
| `runtime_write_memory` | Write 1, 2, or 4 bytes of emulated memory |
| `runtime_get_copper_state` | Get Copper state |
| `runtime_get_blitter_state` | Get Blitter state (busy, channels, size) |
| `runtime_get_drive_state` | Get floppy drive state (track, side, motor) |
| `runtime_get_audio_state` | Get audio channel states |
| `runtime_get_dma_state` | Get DMA channel states |
| `runtime_debug_gdb_server_status` | Get the GDB server state: `enabled`, `port`, `listening`, `connected`, and `error` |
| `runtime_debug_gdb_server_enable` | Turn the GDB server on, optionally on another `port`, and wait for it to listen |
| `runtime_debug_gdb_server_disable` | Turn the GDB server off; an attached client is disconnected |

### Runtime: debugger monitor

`MONITOR` runs the GDB monitor command set without a GDB client. The typed
tools below build the command, check the arguments, and parse the JSON reply.
`runtime_monitor` sends one raw command string. The HTTP API exposes the raw
command as `POST /runtime/debug/monitor`.

| Tool | Actions |
|------|---------|
| `runtime_monitor` | Raw monitor text |
| `runtime_execution_status` | CPU, pause, frame, and beam |
| `runtime_tasks` | Exec task lists |
| `runtime_segments` | AmigaDOS segments |
| `runtime_memory` | `map`, `check` |
| `runtime_exception` | `status`, `mask` |
| `runtime_watch` | `add`, `range`, `list`, `remove`, `events`, `last`, `clear-events` |
| `runtime_dma_watch` | `add`, `list`, `remove` |
| `runtime_condition` | `add`, `list`, `remove` |
| `runtime_history` | `on`, `off`, `read` |
| `runtime_guest_output` | `on`, `off`, `read`, `clear` |
| `runtime_process_break` | `name`, `address`, `status`, `clear` |
| `runtime_input` | `event`, `release`, `status` |

Read-only queries work while the guest runs, except guest RAM reads when
`cpu_threaded=true`.

These actions change debugger state and need the emulation paused (`PAUSE`) or
the native debugger stopped:

- watch `add`, `range`, `remove`, `clear-events`
- DMA watch `add`, `remove`
- condition `add`, `remove`
- exception `mask`
- history `on`, `off`
- guest output `on`, `off`, `clear`
- process break `name`, `address`, `clear`

A watch, condition, exception, or process-entry hit stops in the native
debugger. `runtime_debug_status` then reports `stopped=1` and a `reason=`
(`T05awatch:...`, `T05breakpoint:N;`, `T05winuae-exception:...`,
`T05winuae-entry:...`). `DEBUG_CONTINUE` resumes. The monitor refuses
`step-over`, `checkpoint`, and `input sequence`.

Watch `add` and `range` take nine fields: address, size, access, source mask,
value enabled, value, value mask, change-only, and log-only. Numbers are
hexadecimal. Access is 1 for read, 2 for write, 3 for both; a range can also
set bit 2 for instruction fetch. Change-only requires a write. An exact watch
cannot include the CPU instruction source.

### Instances and IPC

| Tool | Description |
|------|-------------|
| `get_active_instance` | Show which Amiberry instance the server controls |
| `set_active_instance` | Choose an instance (0, 1, 2, ...; `null` to auto-discover) |
| `check_ipc_connection` | Check whether the IPC endpoint is reachable |
| `runtime_ping` | Test the IPC connection (returns `PONG`) |
| `runtime_get_version` | Get Amiberry and SDL versions from the running emulator |
| `runtime_help` | List the IPC commands the running Amiberry accepts |

## Screenshot-driven GUI automation

GUI actions use coordinates taken from a screenshot. Call
`runtime_screenshot_view`, look at the returned image, and pass pixel
coordinates from that exact image to `runtime_gui_move`, `runtime_gui_click`,
or `runtime_gui_drag`. Every action also takes the returned `capture_id` and a
`request_id` that the caller generates.

The screenshot metadata declares `coordinate_space="screenshot_pixels"`, the
image size, and a half-open `actionable_bounds` rectangle. Points must be
integer pixels inside both the image and those bounds. The server translates
them for scaling, HiDPI, viewport, and monitor layout; callers should not
convert coordinates themselves.

| Tool | Required fields | Optional fields |
|------|-----------------|-----------------|
| `runtime_gui_move` | `capture_id`, `request_id`, `x`, `y` | `dwell_ms` (default `0`, range `0..5000`) |
| `runtime_gui_click` | `capture_id`, `request_id`, `x`, `y` | `button` (`left`, `right`, or `middle`; default `left`), `click_count` (`1` or `2`; default `1`) |
| `runtime_gui_drag` | `capture_id`, `request_id`, `start_x`, `start_y`, `end_x`, `end_y` | `button` (`left`, `right`, or `middle`; default `left`) |

`request_id` is 1-128 characters from `A-Z`, `a-z`, `0-9`, `.`, `_`, `:`, and
`-`. Retrying with the same ID and payload returns the original result with
`deduplicated=true`. Reusing an ID with a different payload returns
`request_id_conflict`. The server keeps only a bounded number of past results,
so an ID deduplicates retries within that window, not forever.

Each action returns a versioned result with `ok`, `code`, `message`,
`controller_id`, `request_id`, `action`, `execution_state`, `failure_phase`,
`next_action`, `retryable`, `recapture_required`, `cleanup_state`,
`cleanup_context`, `deduplicated`, and capture, runtime, and coordinate
context. Follow `next_action` and `recapture_required` when recovering from a
failure. `cleanup_unconfirmed` means the outcome is unknown: check what is on
screen before deciding whether to repeat the action.

Captures and request IDs belong to one controller process. A capture stays
valid only while its instance, runtime identity, monitor, and geometry
revision still match; take a new screenshot whenever the result asks for one.
Use either the MCP server or the HTTP server as the controller for a given
Amiberry instance, not both at once.

Older Amiberry builds still return a screenshot, but the metadata has
`actionable=false`, `capture_id=null`, and `next_action="upgrade_runtime"`.
Actionable captures need Amiberry's SDL or OpenGL renderer. The Vulkan
renderer returns plain screenshots and rejects GUI actions, because it cannot
yet tie screenshot pixels to the geometry of the presented frame. There is no
fallback to relative coordinates. GUI automation is supported on Linux,
macOS, and Windows. The Windows named-pipe path was validated live against
an installed Amiberry build: actionable capture, the guarded configuration
compare-and-set, clicks, drags, and stale-capture rejection after a window
resize and after a restart all behaved as specified, with held buttons read
back from the emulated CIA registers. Automated tests cover the action
contract and coordinate geometry; each release is also checked against a
live Amiberry separately.

## Keyboard layouts and pasting

`runtime_send_text` sends raw key presses. The keymap active in the guest turns
them into characters, so on a guest with, say, a Spanish keymap a US-typed `:`
arrives as `Ñ`. Tell the tool which keymap the guest uses and it presses the
keys that produce each character there, including Shift, Alt and dead-key
accents (`é` is the acute key followed by `e`).

- Pass `keymap` with a host path to an AmigaOS keymap file. This is the file the
  guest loads with `SetMap`, `SetKeyboard` or the Input preferences, for example
  a copy of `DEVS:Keymaps/e` or the file from an Aminet keymap archive. A file
  on a directory-mounted hard drive works too, using its host path.
- Set the `AMIBERRY_KEYMAP` environment variable to use a keymap by default.
  The `keymap` argument overrides it.
- With neither, the US keymap is assumed.
- An unreadable or invalid keymap file is an error. The tool never falls back
  to US. Keymap files are limited to 64 KiB and parsed ones are cached.
- Characters the keymap cannot produce, and anything above U+00FF, are skipped
  and listed in the result.

`runtime_paste_text` avoids keymaps altogether: it places the text on the guest
clipboard and presses Right Amiga+V. It needs:

- an Amiberry build that has the `SET_CLIPBOARD` and `GET_CLIPBOARD_STATE` IPC
  commands (an older build answers with a message saying so),
- clipboard sharing enabled in the Amiberry configuration,
- the uae boot ROM and filesystem active in the guest, which provide the
  clipboard task,
- a focused guest application that pastes on Right Amiga+V. A Shell does when
  ConClip runs.

The guest receives the text in ISO-8859-1. Typographic quotes and dashes become
their ASCII forms and other characters outside Latin-1 arrive as `?`. The tool
does not change the host clipboard and, like `runtime_monitor`, works over the
Unix socket or Windows pipe only, not D-Bus. Set `press_return` to press Return
after the paste.

## Debugging Amiga programs

Two sets of tools debug code running in the emulated Amiga. Both work on the
same emulated CPU, and an assistant can use either one or both.

### The built-in debugger tools

These need only IPC and no GDB client:

- `runtime_debug_activate`, `runtime_debug_step`, `runtime_debug_step_over`,
  `runtime_debug_continue`, and `runtime_debug_status` drive the native
  debugger. `runtime_debug_status` reports `stopped=1` and a `reason=` when a
  watch, condition, exception, or process-entry hit stopped the CPU.
- `runtime_set_breakpoint`, `runtime_clear_breakpoint`, and
  `runtime_list_breakpoints` manage PC breakpoints (20 slots).
- `runtime_get_cpu_regs`, `runtime_get_custom_regs`, `runtime_disassemble`,
  `runtime_read_memory`, and `runtime_write_memory` inspect and change state.
- `runtime_monitor` and the typed tools after it run the GDB monitor commands
  directly (see [Runtime: debugger monitor](#runtime-debugger-monitor)). The
  ones that matter most for a program under test:
  - `runtime_process_break` with `name` (or `address`) arms a one-shot stop at
    the entry of an AmigaDOS program. `status` and `clear` inspect or cancel it.
  - `runtime_segments` lists the loaded AmigaDOS segments, which gives the
    load addresses. `runtime_tasks` lists the Exec tasks.
  - `runtime_watch` adds CPU data watchpoints; `runtime_condition` adds
    conditional breakpoints.
  - `runtime_guest_output` captures the debug messages a guest program sends
    through uaelib function 86.
  - `runtime_execution_status` reports CPU, host-pause, frame, and beam state
    without stopping the guest.

### GDB remote debugging

Amiberry can also expose the emulated 68k to a GDB client over the GDB remote
serial protocol (Amiberry 8.4.1 and later). The server is off by default. The
Amiberry repository describes it in `docs/gdb-debugging.md`; this section
covers what matters when driving it from here.

**Turning it on.** Any of these works:

- Launch argument: `gdb_port` on `launch_amiberry`, `launch_with_logging`, or
  `launch_and_wait_for_ipc`, and `gdb_port` in the JSON body of `/launch`,
  `/launch-with-logging`, and `/launch-and-wait`.
  It passes `-s debugging_features=gdbserver -s gdb_port=<port>`, so it
  replaces any other `debugging_features` values that the configuration sets
  for that run. This works on Amiberry 8.4.1 and later.
- At run time: `runtime_debug_gdb_server_enable` (optional `port`, default
  2345 unless the configuration says otherwise). It waits up to three seconds
  and reports whether the server is listening. Use
  `runtime_debug_gdb_server_status` to read `enabled`, `port`, `listening`,
  and `connected` (plus `error` when Amiberry could not open the port), and
  `runtime_debug_gdb_server_disable` to turn it off again. A client that is
  attached gets disconnected and emulation resumes. These three tools need an
  Amiberry with the `GDB_SERVER_*` IPC commands; an older build answers with
  an error that names the launch argument and the GUI as the alternatives.
  Like the GUI checkbox, the change is a run-time preference and survives
  only if the configuration is saved.
- GUI: tick **GDB server** in the Miscellaneous panel and set the **Port**.
  The native macOS, iOS, Android, and Windows apps have no such control.
- Configuration: `debugging_features=gdbserver` and `gdb_port=2345` in the
  `.uae` file, or `amiberry -s debugging_features=gdbserver -s gdb_port=2345`.

**Connecting.** Use a GDB that supports m68k: `m68k-amigaos-gdb`,
`m68k-elf-gdb`, or `gdb-multiarch`.

```text
(gdb) set endian big
(gdb) set architecture m68k
(gdb) target remote 127.0.0.1:2345
```

`gdb-multiarch` needs `set endian big` when no m68k executable is loaded;
without it every register shows byte-swapped. The server reports a memory map
of RAM and ROM, so GDB refuses other addresses. To read custom chip registers
at `$DFF000-$DFF1FF`, run `set mem inaccessible-by-default off` first. The CPU
stops at the next debugger boundary when a client attaches, so unpause the
emulation first if it is paused. While the CPU is stopped the Amiberry window
does not update. `detach`, or closing the client, resumes the emulation and
removes the breakpoints and watchpoints the client set; breakpoints set from
Amiberry's own debugger stay.

**What GDB gets.** Integer registers (read and write), RAM and ROM reads, RAM
writes, custom register reads and aligned word writes, single step, range
stepping, PC breakpoints, and data watchpoints (`watch`, `rwatch`, `awatch`).
GDB's `monitor` command reaches the same monitor commands as
`runtime_monitor`; `monitor capabilities` lists what the running build offers.
Memory addresses are physical. Nothing here loads symbols from Amiga hunk
files: addresses come from `monitor segments` and from your own build output.

**IPC and GDB share the monitor state.** While a GDB client is connected,
Amiberry refuses IPC changes to that state: state-changing `runtime_monitor`
calls and the typed monitor tools. A GDB connection is refused while IPC holds
monitor state, for example an armed `runtime_process_break`, a watch, a
condition, an exception mask, history recording, or captured guest output.
Pause the emulation (`pause_emulation`), clear that state
(`runtime_process_break` with `clear`, `runtime_watch` with `remove`, and so
on) and resume before attaching, or set it from the GDB side with `monitor`
commands instead. PC breakpoints from `runtime_set_breakpoint` are not part of
that state: they are accepted while GDB is attached, stay active, and still
stop the CPU in Amiberry's own debugger after GDB detaches, so clear them
with `runtime_clear_breakpoint` when you are done.

**Security and threading.** The server listens on 127.0.0.1 only and accepts
one client at a time. It has no authentication: any local process that
connects gets full control of the guest. While the server is enabled, the CPU
emulation runs on the main thread instead of a CPU thread of its own.

### Workflow: debugging a native program

1. Start the server: launch with `gdb_port` (for example 2345), or call
   `runtime_debug_gdb_server_enable` and check that the status says
   `listening`.
2. Attach GDB with the three commands above. The CPU stops.
3. In GDB, run `monitor process-break name MYPROGRAM`, then `continue`. The
   first command arms a one-shot stop at the entry of that AmigaDOS program.
   Setting it from GDB keeps IPC out of the monitor state.
4. Start the program in the guest, for example by typing its name in a Shell
   (`runtime_send_text` works while GDB is attached and the CPU runs). The
   CPU stops at the program's entry and GDB reports it as a `SIGTRAP`.
5. Run `monitor segments` for the loaded segments. Their addresses are
   decimal; the entry PC is the first segment's address. Use them to place
   breakpoints (`break *0x...`) and to read code with `x/i $pc` or
   `x/20i 0x...`. Then `stepi`, `continue`, `info registers`, and watchpoints
   work as in any GDB session.
6. `detach` when done. The emulation resumes.

Without a GDB client, the same steps work through IPC. Pause the emulation,
call `runtime_process_break` with `name`, resume, and start the program. When
`runtime_debug_status` shows `stopped=1` with a `reason` that begins
`T05winuae-entry`, call `runtime_segments`, set breakpoints, step, and read
registers with the tools above, then `runtime_debug_continue`.
`runtime_debug_step` returns before the step has run: wait until
`runtime_debug_status` shows the CPU stopped again before reading registers or
continuing, or the read shows the old PC and the continue fails. A process
break that has not fired is still monitor state; clear it before attaching
GDB.

## Example prompts

**Library and launching**
- "List my Amiberry configurations"
- "Find disk images containing 'Shadow of the Beast'"
- "Launch Amiberry with the A1200 model"
- "Launch the WHDLoad game 'Turrican'"
- "Launch the CD32 game from /path/to/game.iso"
- "Create a new A1200 config with 8MB Fast RAM"
- "What CPU and chipset does my savestate use?"

**Running emulation**
- "Pause the emulation" / "Take a screenshot"
- "Quick save to slot 0"
- "Insert disk 2 into drive DF0"
- "Set the floppy speed to 800" / "Enable warp mode"
- "Switch to the AGA chipset and a 68030 CPU"
- "Set Chip RAM to 2MB"
- "Type 'dir' and press Return"

**Debugging**
- "Launch Amiberry with logging enabled and show me the log"
- "Activate the debugger and show me the CPU registers"
- "Disassemble at 0xFC0000"
- "Set a breakpoint at 0x400 and continue"
- "Get the Copper and Blitter state"
- "Start Amiberry with the GDB server on port 2345"
- "Is the GDB server listening? Which port?"
- "Stop at the entry of MyProgram and show me its segments"

## HTTP API

The HTTP server (FastAPI) exposes the same functions as REST endpoints for
scripts, home automation, and voice assistants such as Siri Shortcuts.

```bash
uvx --from "amiberry-mcp-server[http]" amiberry-http
```

With the package installed (`pipx install "amiberry-mcp-server[http]"` or
`pip install "amiberry-mcp-server[http]"`), run `amiberry-http`. From a clone,
the scripts install the dependencies and start the server (on macOS and Linux
they can also set it up to start at login, see below):

```bash
./scripts/install_http_api.sh   # install the HTTP dependencies
./scripts/start_http_api.sh     # start the server
```

The API listens on `http://localhost:8080` by default; set
`AMIBERRY_HTTP_HOST` and `AMIBERRY_HTTP_PORT` to change it. Interactive docs
are at `http://localhost:8080/docs`.
[docs/HTTP_API_GUIDE.md](https://github.com/BlitterStudio/amiberry-mcp-server/blob/main/docs/HTTP_API_GUIDE.md)
has request formats, curl examples for every endpoint, and voice assistant
setup.
[docs/QUICKSTART_HTTP_API.md](https://github.com/BlitterStudio/amiberry-mcp-server/blob/main/docs/QUICKSTART_HTTP_API.md)
is a short reference.

A few examples:

```bash
# Launch a model, list configs, stop Amiberry
curl -X POST http://localhost:8080/quick-launch/A500
curl http://localhost:8080/configs
curl -X POST http://localhost:8080/stop

# Launch a WHDLoad game
curl -X POST "http://localhost:8080/launch-whdload?search=Turrican"

# Control a running emulation
curl -X POST http://localhost:8080/runtime/pause
curl -X POST http://localhost:8080/runtime/insert-floppy \
  -H "Content-Type: application/json" \
  -d '{"drive": 0, "image_path": "/path/to/disk2.adf"}'
curl -X POST http://localhost:8080/runtime/type \
  -H "Content-Type: application/json" \
  -d '{"text": "dir\n", "delay_ms": 50}'

# Debugger
curl -X POST http://localhost:8080/runtime/breakpoints \
  -H "Content-Type: application/json" \
  -d '{"address": "0x400", "slot": 2}'
curl http://localhost:8080/runtime/cpu/regs
```

### Endpoints

Endpoints under `/runtime` need a running Amiberry with IPC support.

#### Library, launching, and processes

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | API name, version, platform, status |
| `/status` | GET | Check whether Amiberry is running |
| `/stop` | POST | Stop all Amiberry instances |
| `/platform` | GET | Platform info |
| `/version` | GET | Amiberry version |
| `/configs` | GET | List configurations |
| `/configs/{name}` | GET | Raw config file contents |
| `/configs/{name}/parsed` | GET | Parsed config as JSON |
| `/configs/create/{name}` | POST | Create a config from a template |
| `/configs/{name}` | PATCH | Modify a config |
| `/disk-images` | GET | List disk images |
| `/cd-images` | GET | List CD images |
| `/savestates` | GET | List savestates |
| `/savestates/{name}/inspect` | GET | Savestate metadata |
| `/roms` | GET | List identified ROMs |
| `/roms/identify` | GET | Identify a ROM by the `rom_path` query parameter (must be inside the Amiberry home directory) |
| `/launch` | POST | Launch with full options (`gdb_port` starts the GDB server) |
| `/quick-launch/{name}` | POST | Launch by model or config name |
| `/launch-with-logging` | POST | Launch with log capture (accepts `gdb_port`) |
| `/launch-lha` | POST | Launch an `.lha` archive |
| `/launch-whdload` | POST | Launch a WHDLoad game |
| `/launch-cd` | POST | Launch a CD image |
| `/launch-and-wait` | POST | Launch and wait until IPC is ready (accepts `gdb_port`) |
| `/disk-swapper` | POST | Set up the disk swapper |
| `/logs` | GET | List captured logs |
| `/logs/{name}` | GET | Log contents |
| `/logs/tail` | POST | Log lines added since the last read |
| `/logs/wait-for-pattern` | POST | Wait for a regex in the log |
| `/health` | GET | Process, IPC, and emulation status in one call |
| `/process/alive` | GET | Check whether the process is running |
| `/process/info` | GET | Process details with crash detection |
| `/process/kill` | POST | Force-kill the process |
| `/process/wait-for-exit` | POST | Wait for the process to exit |
| `/process/restart` | POST | Kill and relaunch with the same command |
| `/process/crash-info` | POST | Detect a crash from process state and logs |

#### Runtime: emulation and state

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/runtime/status` | GET | Emulation status |
| `/runtime/pause` | POST | Pause |
| `/runtime/resume` | POST | Resume |
| `/runtime/reset` | POST | Soft or hard reset |
| `/runtime/quit` | POST | Quit Amiberry |
| `/runtime/frame-advance` | POST | Advance N frames while paused |
| `/runtime/screenshot` | POST | Save a screenshot |
| `/runtime/screenshot-view` | POST | Screenshot bytes plus capture metadata |
| `/runtime/save-state` | POST | Save state |
| `/runtime/load-state` | POST | Load a savestate |
| `/runtime/quicksave` | POST | Quick save to slot 0-9 |
| `/runtime/quickload` | POST | Quick load from slot 0-9 |
| `/runtime/config/{option}` | GET | Get a config option |
| `/runtime/config` | POST | Set a config option |
| `/runtime/configs` | GET | List configs known to the emulator |
| `/runtime/load-config` | POST | Load a `.uae` file into the running emulation |
| `/runtime/led-status` | GET | LED states |
| `/runtime/fps` | GET | Frame rate and idle percentage |

#### Runtime: media

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/runtime/insert-floppy` | POST | Insert a floppy |
| `/runtime/eject-floppy` | POST | Eject a floppy |
| `/runtime/list-floppies` | GET | List floppy drives and their contents |
| `/runtime/disk-swap` | POST | Insert a swapper disk (`{"disk_num", "drive"}`) |
| `/runtime/disk-swap/{drive}` | GET | Swapper slot in a drive |
| `/runtime/floppy-speed` | GET | Floppy speed |
| `/runtime/floppy-speed` | POST | Set floppy speed (0=turbo, 100=1x, 200=2x, 400=4x, 800=8x) |
| `/runtime/disk-write-protect/{drive}` | GET | Write protection for a drive |
| `/runtime/disk-write-protect` | POST | Set write protection |
| `/runtime/insert-cd` | POST | Insert a CD image |
| `/runtime/eject-cd` | POST | Eject the CD |
| `/runtime/harddrives` | GET | List mounted hard drives |
| `/runtime/whdload` | GET | Loaded WHDLoad game |
| `/runtime/whdload` | POST | Load a WHDLoad game (LHA or directory) |
| `/runtime/whdload` | DELETE | Eject the WHDLoad game |

#### Runtime: hardware

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/runtime/chipset` | GET | Chipset |
| `/runtime/chipset` | POST | Set chipset (OCS, ECS_AGNUS, ECS_DENISE, ECS, AGA) |
| `/runtime/cpu-model` | GET | CPU model |
| `/runtime/cpu-model` | POST | Set CPU model (68000, 68010, 68020, 68030, 68040, 68060) |
| `/runtime/cpu-speed` | GET | CPU speed |
| `/runtime/cpu-speed` | POST | Set CPU speed (-1=max, 0=cycle-exact, >0=percent) |
| `/runtime/memory-config` | GET | Memory sizes (chip, fast, bogo, Z3, RTG) |
| `/runtime/chip-mem` | POST | Set Chip RAM (256, 512, 1024, 2048, 4096, 8192 KB) |
| `/runtime/fast-mem` | POST | Set Fast RAM (0, 1024, 2048, 4096, 8192 KB) |
| `/runtime/slow-mem` | POST | Set Slow (Bogo) RAM (0, 256, 512, 1024, 1792 KB) |
| `/runtime/z3-mem` | POST | Set Zorro III RAM (0-1024 MB) |

Memory changes take effect after a reset.

#### Runtime: display and sound

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/runtime/fullscreen` | POST | Toggle fullscreen |
| `/runtime/display-mode` | GET | Display mode |
| `/runtime/display-mode` | POST | Set display mode (0=window, 1=fullscreen, 2=fullwindow) |
| `/runtime/window-size` | GET | Window size |
| `/runtime/window-size` | POST | Set window size (width x height) |
| `/runtime/scaling` | GET | Scaling mode |
| `/runtime/scaling` | POST | Set scaling (-1=auto, 0=nearest, 1=linear, 2=integer) |
| `/runtime/line-mode` | GET | Line mode |
| `/runtime/line-mode` | POST | Set line mode (single, double, scanlines) |
| `/runtime/resolution` | GET | Resolution |
| `/runtime/resolution` | POST | Set resolution (lores, hires, superhires) |
| `/runtime/autocrop` | GET | Autocrop state |
| `/runtime/autocrop` | POST | Turn autocrop on or off |
| `/runtime/ntsc` | GET | Video mode (PAL or NTSC) |
| `/runtime/ntsc` | POST | Set video mode |
| `/runtime/rtg` | POST | Switch between RTG and chipset display |
| `/runtime/status-line` | POST | Cycle the status line (off, chipset, RTG, both) |
| `/runtime/warp` | GET | Warp mode |
| `/runtime/warp` | POST | Set warp mode |
| `/runtime/volume` | GET | Volume |
| `/runtime/volume` | POST | Set volume (0-100) |
| `/runtime/mute` | POST | Mute |
| `/runtime/unmute` | POST | Unmute |
| `/runtime/sound-mode` | GET | Sound mode |
| `/runtime/sound-mode` | POST | Set sound mode (0=off, 1=normal, 2=stereo, 3=best) |

#### Runtime: input and GUI automation

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/runtime/key` | POST | Send a key (keycode and state) |
| `/runtime/type` | POST | Type a string (optional `keymap` path) |
| `/runtime/paste` | POST | Paste text through the guest clipboard |
| `/runtime/mouse` | POST | Send mouse input |
| `/runtime/mouse-speed` | GET | Mouse sensitivity |
| `/runtime/mouse-speed` | POST | Set mouse sensitivity |
| `/runtime/mouse-grab` | POST | Toggle mouse capture |
| `/runtime/joyport/{port}` | GET | Port mode |
| `/runtime/joyport` | POST | Set port mode |
| `/runtime/autofire/{port}` | GET | Autofire mode |
| `/runtime/autofire` | POST | Set autofire mode |
| `/runtime/gui/move` | POST | Move or hover at a screenshot pixel |
| `/runtime/gui/click` | POST | Click or double-click at a screenshot pixel |
| `/runtime/gui/drag` | POST | Drag between screenshot pixels |

#### Runtime: debugging

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/runtime/debug/activate` | POST | Enter the debugger |
| `/runtime/debug/deactivate` | POST | Leave the debugger and resume |
| `/runtime/debug/status` | GET | Debugger status |
| `/runtime/debug/step` | POST | Single-step instructions |
| `/runtime/debug/step-over` | POST | Step over subroutine calls (JSR, BSR) |
| `/runtime/debug/continue` | POST | Continue execution |
| `/runtime/debug/monitor` | POST | Run one GDB monitor command (`{"text": "tasks"}`) |
| `/runtime/debug/gdb-server` | GET | GDB server state (`enabled`, `port`, `listening`, `connected`, `error`) |
| `/runtime/debug/gdb-server/enable` | POST | Turn the GDB server on (optional `{"port": 2345}`) and wait for it to listen |
| `/runtime/debug/gdb-server/disable` | POST | Turn the GDB server off |
| `/runtime/cpu/regs` | GET | CPU registers |
| `/runtime/custom/regs` | GET | Custom chip registers |
| `/runtime/disassemble` | POST | Disassemble at an address |
| `/runtime/breakpoints` | GET | List breakpoints |
| `/runtime/breakpoints` | POST | Set a breakpoint (`address`, optional `slot` 0-19) |
| `/runtime/breakpoints` | DELETE | Clear breakpoints |
| `/runtime/memory/read` | POST | Read 1, 2, or 4 bytes of memory |
| `/runtime/memory/write` | POST | Write 1, 2, or 4 bytes of memory |
| `/runtime/copper/state` | GET | Copper state |
| `/runtime/blitter/state` | GET | Blitter state |
| `/runtime/drive/state` | GET | Floppy drive state |
| `/runtime/audio/state` | GET | Audio channel states |
| `/runtime/dma/state` | GET | DMA channel states |

#### Runtime: instances and IPC

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/runtime/active-instance` | GET | Instance being controlled |
| `/runtime/active-instance` | POST | Choose an instance (`null` to auto-discover) |
| `/runtime/ipc-check` | GET | Check IPC availability |
| `/runtime/ping` | GET | Test the IPC connection |
| `/runtime/version` | GET | Amiberry version from the running emulator |
| `/runtime/help` | GET | List IPC commands |

### Starting at login

`install_http_api.sh` creates a LaunchAgent on macOS and a systemd user unit
on Linux. Enable them with:

```bash
# macOS
launchctl load ~/Library/LaunchAgents/com.amiberry.httpapi.plist

# Linux
systemctl --user enable --now amiberry-http-api.service
```

## Troubleshooting

### The tools do not appear in the client
- Quit and reopen the client. Most clients load MCP servers only at startup.
- If the entry uses `uvx`, check that the client can find it: GUI clients often
  have a shorter `PATH` than your shell, so put the full path of `uvx` (from
  `which uvx`, or `where uvx` on Windows) in `command`.
- If the entry points at a clone, check that the `command` path is this
  project's `venv/bin/python` (`venv\Scripts\python.exe` on Windows) and that
  the file exists.
- Run `uvx amiberry-mcp-server`, `amiberry-mcp-server`, or
  `python -m amiberry_mcp.server` from the virtual environment. It should wait
  silently for input on stdin; if it prints an error, fix that first.
- Read the client's MCP log:
  - Claude Desktop (macOS): `~/Library/Logs/Claude/mcp*.log`
  - Claude Code: `claude mcp list`, then check the server's stderr
  - Cursor: View → Output → "MCP" channel

### "Command not found" when launching
- **Linux and FreeBSD**: put `amiberry` on `PATH`
- **macOS**: install `Amiberry.app` in `/Applications`
- **Windows**: install Amiberry with its installer, or put `Amiberry.exe` on
  `PATH`. The server checks `PATH` first, then the installer's registry entry
  (HKCU, then HKLM), then `%LOCALAPPDATA%\Programs\amiberry\Amiberry.exe` and
  `%ProgramFiles%\amiberry\Amiberry.exe`. Set `AMIBERRY_BINARY` to point at
  any other copy, such as a portable one.

### Permission errors running the scripts
Make them executable: `chmod +x scripts/*.sh`

### Where captured logs go
The `logs` directory under the content root: `~/Documents/Amiberry/logs` on
macOS, `~/Amiberry/logs` on Linux and FreeBSD, `%USERPROFILE%\Amiberry\logs`
on Windows.

### Runtime control does not work
- Check that Amiberry is running and was built with `USE_IPC_SOCKET=ON`
  (a CMake option).
- On Linux, FreeBSD, and macOS, check that the socket exists:
  `ls "${XDG_RUNTIME_DIR:-/tmp}/amiberry.sock"`. Test it directly with
  `echo "GET_STATUS" | nc -U "${XDG_RUNTIME_DIR:-/tmp}/amiberry.sock"`.
- With several instances running, instance 0 uses `amiberry.sock` and the
  others use `amiberry_1.sock`, `amiberry_2.sock`, and so on up to instance 9.
  Pick one with `set_active_instance`.
- On Windows, list the pipes with
  `Get-ChildItem \\.\pipe\ | Where-Object Name -like 'amiberry*'`. Do not use
  `Test-Path`: it opens a client connection to the pipe.
- The Windows pipe transport needs asyncio's Proactor event loop, which is the
  default on Windows. If a dependency switches to a selector loop, the server
  reports an error saying so.

### The GDB server does not listen
- `runtime_debug_gdb_server_status` reports `enabled=1` but `listening=0` when
  the port is in use, when the emulation is not running yet, or when the
  server was just enabled and Amiberry has not polled it. The reply carries
  Amiberry's `error=` text when it has one. Try another port with
  `runtime_debug_gdb_server_enable`.
- An error that says the Amiberry "does not support GDB_SERVER_STATUS" means
  a build without the `GDB_SERVER_*` IPC commands. Start the server with the
  `gdb_port` launch argument or in the GUI's Miscellaneous panel instead; both
  work on Amiberry 8.4.1 and later.
- A GDB client that connects and gets refused, or `runtime_monitor` refusing
  a state change, is the ownership rule described in
  [Debugging Amiga programs](#debugging-amiga-programs).

## Development

```bash
git clone https://github.com/BlitterStudio/amiberry-mcp-server.git
cd amiberry-mcp-server
python3 -m venv venv
source venv/bin/activate
pip install -e ".[all]"         # HTTP, D-Bus, and dev dependencies

pytest tests/ -v                # run the tests
ruff check src/ tests/          # lint
ruff format src/ tests/         # format
```

GitHub Actions runs the lint, format check and tests on Linux, macOS and
Windows for every pull request, and builds the package and starts it from the
built wheel.

### Releasing

1. Set the new version in `pyproject.toml` and in `src/amiberry_mcp/__init__.py`.
2. Add the release text as `.github/release-notes/vX.Y.Z.md`.
3. Merge to `main`, then push the tag: `git tag vX.Y.Z && git push origin vX.Y.Z`.

The release workflow checks that the tag matches the version in
`pyproject.toml`, builds the sdist and wheel, tests the installed wheel,
publishes it to PyPI through trusted publishing (the `pypi` environment), and
creates the GitHub release with the notes file and the built files attached.

Project layout:

```
amiberry-mcp-server/
├── src/amiberry_mcp/
│   ├── config.py          # platform detection and paths
│   ├── common.py          # shared helpers (launch, scan, validation)
│   ├── shared_state.py    # process state, IPC client caching, launch helpers
│   ├── server.py          # MCP server (154 tools)
│   ├── http_server.py     # HTTP API (FastAPI)
│   ├── ipc_client.py      # IPC client (Unix socket, named pipe, D-Bus)
│   ├── monitor.py         # MONITOR command builders and reply parsing
│   ├── amiga_keymap.py    # AmigaOS keymap parser and typing tables
│   ├── gui_automation.py  # screenshot capture registry and GUI actions
│   ├── uae_config.py      # .uae parser and generator
│   ├── savestate.py       # .uss metadata parser
│   └── rom_manager.py     # ROM identification
├── scripts/               # install, uninstall, HTTP API and release smoke-test scripts
├── .github/               # CI and release workflows, release notes
├── tests/                 # pytest suite, one file per module
├── docs/                  # HTTP API guide and quick reference
└── AGENTS.md              # architecture and code conventions
```

## Uninstall

Installed from PyPI: run `pip uninstall amiberry-mcp-server` or
`pipx uninstall amiberry-mcp-server`. `uvx` keeps no installation, only a
cache; `uv cache clean amiberry-mcp-server` removes it. Then remove the
`amiberry` entry from your client's configuration.

From a clone:

```bash
./scripts/uninstall.sh
```

## Contributing

Issues and pull requests are welcome.
[AGENTS.md](https://github.com/BlitterStudio/amiberry-mcp-server/blob/main/AGENTS.md)
describes the architecture and code conventions: ruff settings, type
annotations, error handling, and test layout.

## License

GPL-3.0. See [LICENSE](https://github.com/BlitterStudio/amiberry-mcp-server/blob/main/LICENSE).

## Links

- [Model Context Protocol](https://modelcontextprotocol.io)
- [Amiberry](https://github.com/BlitterStudio/amiberry)
- [FastAPI](https://fastapi.tiangolo.com)
- MCP clients: [Claude Desktop](https://claude.ai/download),
  [Claude Code](https://claude.com/claude-code),
  [Codex](https://github.com/openai/codex), [Cursor](https://cursor.com),
  [Cline](https://github.com/cline/cline), [Continue](https://continue.dev),
  [Windsurf](https://codeium.com/windsurf)
