# Geargrafx MCP Server A [Model Context Protocol](https://modelcontextprotocol.io/introduction) server for the Geargrafx emulator, enabling AI-assisted debugging and development of TurboGrafx-16 / PC Engine / SuperGrafx games. This server provides tools for game development, rom hacking, reverse engineering, and debugging through standardized MCP protocols compatible with AI agents like Claude Code, Codex and others. ## Downloads These MCP Bundles (`.mcpb`) package Geargrafx with its MCP server configuration for MCP clients that install bundles, and are the packages published to the [MCP Registry](https://registry.modelcontextprotocol.io/). Claude Code and Codex use a regular Geargrafx build instead, see [Quick Start](#quick-start).
Platform Architecture Download Link
Windows x64 Geargrafx-1.8.10-mcpb-windows-x64.mcpb
ARM64 Geargrafx-1.8.10-mcpb-windows-arm64.mcpb
macOS x64 Geargrafx-1.8.10-mcpb-macos-x64.mcpb
ARM64 Geargrafx-1.8.10-mcpb-macos-arm64.mcpb
Linux x64 Geargrafx-1.8.10-mcpb-linux-x64.mcpb
ARM64 Geargrafx-1.8.10-mcpb-linux-arm64.mcpb
## Features - **Full Debugger Access**: CPU registers, memory inspection, breakpoints, and execution control - **Multiple Memory Areas**: Access RAM, VRAM, ROM, CD-ROM RAM, Arcade Card RAM, and more - **Disassembly**: View disassembled code around PC or any address - **Hardware Inspection**: HuC6280 CPU, HuC6270 VDC, HuC6260 VCE, HuC6202 VPC, PSG, CD-ROM subsystems, TurboLink - **Sprite Viewer**: List and inspect all 64 sprites with images - **Symbol Support**: Add, remove, list, and look up debug symbols - **Input State**: Inspect effective pressed buttons and pending tap releases - **Bookmarks**: Memory and disassembler bookmarks for navigation - **Call Stack**: View function call hierarchy - **Trace Logger**: CPU instruction trace with interleaved hardware events (VDC, VCE, PSG, timer, CD-ROM, SCSI, ADPCM, input) - **Profiler**: Per-function call counts, calls per frame, and inclusive/exclusive cycle statistics - **Screenshot Capture**: Get current frame as PNG image - **Video Recording**: Record emulated video and audio to AVI files on disk - **Rewind**: Time-travel debugging with snapshot status and seek tools - **Documentation Resources**: Built-in hardware and programming documentation for AI context - **GUI Integration**: MCP server runs alongside the emulator GUI, sharing the same state ## Transport Modes The Geargrafx MCP server supports two transport modes: ### STDIO Transport (Recommended) The default mode uses standard input/output for communication. The emulator is launched by the AI client and communicates through stdin/stdout pipes. ### HTTP Transport The HTTP transport mode runs the emulator with an embedded web server on `127.0.0.1:7777/mcp` by default. The emulator stays running independently while the AI client connects via HTTP. Each request's `Host` and browser `Origin` must match the address on which its connection reached the server. Loopback mode can run without authentication; wildcard and other non-loopback bind addresses require `GEARGRAFX_MCP_HTTP_TOKEN`, and the server refuses to start without it. ### Headless Mode Add `--headless` to run without a GUI window. This is useful for servers, CLI agents, or any machine without a display. All MCP tools work identically in headless mode. Requires `--mcp-stdio` or `--mcp-http`. A save state can be loaded at launch too, with `--load-state 1` for slot 1 or `--load-state FILE` for a state file; run `geargrafx --help` for the full list. Headless mode is debug mode without rendering, so the debug output settings apply: screenshots use the output overscan and scanline count from the **Debug** menu instead of the ones in the **Video** menu. By default, overscan is disabled and all 242 scanlines are shown. Headless instances read these settings from the configuration file, so set them in the GUI with debug enabled. The same settings apply when the MCP server runs alongside the GUI, because MCP always runs in debug mode. ### Pause When Inactive While the MCP server is running, the emulator keeps running when its window loses focus, even with **Pause When Inactive** enabled in the **Emulator** menu. The setting keeps its value and applies again once the server stops. ### Start Paused `--mcp-stdio` and `--mcp-http` turn the debugger on. Loads and resets then follow **Start Paused** in the **Emulator** menu, as outside the debugger: with it off (the default) the game runs, with it on the debugger stops before the first instruction. `load_media` and `debug_reset` take an optional `stop_at_start` to choose for one call, which also turns the debugger on, and their answers say whether emulation is `paused`. ### Concurrent Clients The HTTP server accepts repeated valid MCP initialization requests. All connected clients control the same Geargrafx instance. Individual HTTP requests are serialized, but multi-request debugging workflows are not atomic. Concurrent agents can interfere with each other through pauses, resets, breakpoints, memory writes, media loads, and save states. For independent agent tasks, run one Geargrafx instance per agent on a unique HTTP port. Use `--headless` and give each instance its own portable application directory so its configuration and runtime files are isolated: ```bash ./geargrafx --mcp-http --headless --portable --mcp-http-port 7778 ``` The `--portable` option stores configuration and user data beside the application. Alternatively, create an empty `portable.ini` beside the executable in each application directory. On macOS, place it next to each `.app` bundle. ### Result Format Tool results are compact JSON, which takes the least of an agent's context; images such as screenshots stay images. Add `--mcp-pretty` to indent the JSON when you read it yourself. ## MCP Tool Router By default, Geargrafx exposes every MCP tool directly. This avoids nested tool discovery in clients that already defer MCP schemas, including Claude Code. Add `--mcp-router` to expose a compact set of high-frequency tools directly and route advanced debugger tools through lightweight discovery tools. This reduces MCP context while preserving access to the full debugger surface. Direct tools in routed mode: `load_media`, `get_media_info`, `debug_pause`, `debug_continue`, `debug_step_into`, `debug_get_status`, `get_huc6280_status`, `read_memory`, `write_memory`, `get_disassembly`, `set_breakpoint`, `get_screenshot`, and `controller_button`. Router tools: - `search_tools` finds direct and routed tools by `query` (words that must all match, or an exact tool name), by `category`, or both. Each match has `name`, `description` and `direct` for a direct tool; with 5 matches or fewer each also has its `inputSchema`, and an exact name match always has it, listed first before the other matches. A `category` search adds the category's description. - `execute_tool` runs a routed tool by `name` with its `arguments`. An unknown name answers with a hint to search, and arguments that don't fit the tool's schema answer with its `inputSchema`. Example routed call: ```json { "name": "get_huc6270_status", "arguments": {} } ``` Without `--mcp-router`, call every MCP tool directly. ## Quick Start Get a desktop build of Geargrafx from the [downloads](README.md#downloads) or [build it from source](README.md#build-instructions). In the examples below, replace `/path/to/geargrafx` with the full path to the executable: - **macOS:** `/Applications/Geargrafx.app/Contents/MacOS/geargrafx` - **Linux:** `/path/to/geargrafx` - **Windows:** `C:/path/to/geargrafx.exe` ### Plugin The Geargrafx plugin sets up the MCP server and installs the [Agent Skills](skills/README.md) in one step. It finds Geargrafx by itself, see the [plugin requirements](https://github.com/drhelius/agent-plugins#requirements). - **Claude Code:** ```bash claude plugin marketplace add drhelius/agent-plugins claude plugin install geargrafx@drhelius ``` - **Codex:** ```bash codex plugin marketplace add drhelius/agent-plugins codex plugin add geargrafx@drhelius ``` - **GitHub Copilot CLI:** ```bash copilot plugin marketplace add drhelius/agent-plugins copilot plugin install geargrafx@drhelius ``` Use the manual setup below for HTTP mode, options such as `--headless` or `--mcp-router`, or other clients. ### STDIO Mode with Claude Code 1. **Add the Geargrafx MCP server** using the CLI: ```bash claude mcp add --transport stdio --scope user geargrafx -- /path/to/geargrafx --mcp-stdio ``` Everything after `--` is passed to Geargrafx untouched. `--scope user` makes the server available in all your projects. Use `--scope local` (the default) to add it only to the current project, or `--scope project` to share it through a `.mcp.json` file in the project root: ```json { "mcpServers": { "geargrafx": { "command": "/path/to/geargrafx", "args": ["--mcp-stdio"] } } } ``` Claude Code asks for approval the first time it uses a server from `.mcp.json`. 2. **Verify the server was added**: ```bash claude mcp list ``` 3. **Start debugging**: Start Claude Code and ask about the game state. Geargrafx launches when the session starts. Run `/mcp` inside Claude Code to check the server status or reconnect it. ### STDIO Mode with Codex The Codex CLI, IDE extension, and desktop app share the same MCP configuration, so you only need to add the server once. 1. **Add the Geargrafx MCP server** using the CLI: ```bash codex mcp add geargrafx -- /path/to/geargrafx --mcp-stdio ``` Or add it to `~/.codex/config.toml`: ```toml [mcp_servers.geargrafx] command = "/path/to/geargrafx" args = ["--mcp-stdio"] ``` To use the server only in one project, add the same table to `.codex/config.toml` in that project. Codex loads project configuration only for trusted projects. In TOML, write Windows paths with forward slashes or in single quotes. 2. **Verify the server was added**: ```bash codex mcp list ``` 3. **Start debugging**: Start Codex and ask about the game state. Geargrafx launches when the session starts. Type `/mcp` in the Codex CLI to see the active servers. ### HTTP Mode 1. **Start the emulator manually** with HTTP transport: ```bash ./geargrafx --mcp-http ``` The default endpoint is `http://127.0.0.1:7777/mcp`. To use a custom port: ```bash ./geargrafx --mcp-http --mcp-http-port 3000 ``` To bind to a custom address, set a bearer token first: ```bash GEARGRAFX_MCP_HTTP_TOKEN="change-this-token" ./geargrafx --mcp-http --mcp-http-address 0.0.0.0 --mcp-http-port 3000 ``` Clients must connect using the server's actual interface address, such as `http://192.168.1.50:3000/mcp`, not `0.0.0.0` or a spoofed loopback address. You can also start the server using the "MCP" menu in the GUI. 2. **Configure bearer-token authentication**: Set `GEARGRAFX_MCP_HTTP_TOKEN` before starting HTTP mode. Authentication is optional for loopback binds and required for wildcard or other non-loopback binds. macOS and Linux: ```bash GEARGRAFX_MCP_HTTP_TOKEN="change-this-token" ./geargrafx --mcp-http ``` Windows PowerShell: ```powershell $env:GEARGRAFX_MCP_HTTP_TOKEN = "change-this-token" .\geargrafx.exe --mcp-http ``` Windows Command Prompt: ```cmd set GEARGRAFX_MCP_HTTP_TOKEN=change-this-token geargrafx.exe --mcp-http ``` 3. **Configure Claude Code**: ```bash claude mcp add --transport http --scope user geargrafx http://127.0.0.1:7777/mcp ``` If the server uses a bearer token, add the header: ```bash claude mcp add --transport http --scope user geargrafx http://127.0.0.1:7777/mcp \ --header "Authorization: Bearer change-this-token" ``` In a shared `.mcp.json`, read the token from the environment instead of committing it: ```json { "mcpServers": { "geargrafx": { "type": "http", "url": "http://127.0.0.1:7777/mcp", "headers": { "Authorization": "Bearer ${GEARGRAFX_MCP_HTTP_TOKEN}" } } } } ``` 4. **Or configure Codex**: ```bash codex mcp add geargrafx --url http://127.0.0.1:7777/mcp ``` If the server uses a bearer token, Codex reads it from an environment variable, so set `GEARGRAFX_MCP_HTTP_TOKEN` in the environment where Codex runs too: ```bash codex mcp add geargrafx --url http://127.0.0.1:7777/mcp --bearer-token-env-var GEARGRAFX_MCP_HTTP_TOKEN ``` The equivalent `~/.codex/config.toml` entry: ```toml [mcp_servers.geargrafx] url = "http://127.0.0.1:7777/mcp" bearer_token_env_var = "GEARGRAFX_MCP_HTTP_TOKEN" ``` 5. **Start a new Claude Code or Codex session** and start debugging > **Note:** The MCP HTTP Server must be running standalone before connecting the AI client. > **Security:** Without `GEARGRAFX_MCP_HTTP_TOKEN`, HTTP mode starts only on a loopback address. Wildcard and other non-loopback binds are refused. `Host` and browser `Origin` values are matched to the connection's actual destination address to prevent DNS rebinding and address spoofing. ## Usage Examples Once configured, you can ask your AI assistant: ### Basic Commands - "What game is currently loaded?" - "Load the ROM at /path/to/game.pce" - "Show me the current CPU registers" - "Read 16 bytes from RAM starting at 0x2000" - "Set a breakpoint at address 0x8000" - "Pause execution and show me all sprites" - "Step through the next 5 instructions" - "Capture a screenshot of the current frame" - "Record a video of the next 600 frames to /path/to/clip.avi" - "Tap the up button on player 1 controller" - "Set player 1 controller to avenue pad 6 type" ### Advanced Debugging Workflows - "Find the VBlank interrupt handler, analyze what it does, and add symbols for all the subroutines it calls" - "Locate the sprite update routine. Study how this game manages its sprite system, explain the algorithm, and add bookmarks to key sections. Also add watches for any sprite-related variables you find" - "There's a data decompression routine around address 0xC000. Step through it instruction by instruction, reverse engineer the compression algorithm, and explain how it works with examples" - "Find where the game stores its level data in ROM. Analyze the data structure format, create a memory map showing each section, and add symbols for the data tables" - "The game is rendering corrupted graphics. Examine the VDC registers, check the VRAM contents, inspect the sprite attribute table, and diagnose what's causing the corruption. Set up watches on relevant memory addresses" - "Profile the game for a few seconds, then tell me which functions use the most CPU time per frame and what they do" ## Available MCP Tools This is the full tool catalog. By default the server lists every tool to the client, and the agent calls each one by its name. With `--mcp-router`, the client sees only the direct tools listed in [MCP Tool Router](#mcp-tool-router) plus `search_tools` and `execute_tool`. Every other tool below still works the same, with the same arguments, but through those two: `search_tools` finds it by words, by its router category or by its exact name, with its input schema when 5 or fewer tools match or the name is exact, and `execute_tool` calls it with its `name` and `arguments`. The server exposes tools organized in the following categories: ### Execution Control - `debug_pause` - Pause emulation - `debug_continue` - Resume emulation - `debug_step_into` - Step one instruction - `debug_step_over` - Step over subroutine calls - `debug_step_out` - Step out of current subroutine - `debug_step_frame` - Step one or more frames. Optional `frames` is 1-1000 (default 1). Optional `mode` is `async` (default, returns after scheduling) or `sync` (returns after all requested frames complete at VBlank). Use `mode: "sync"` when issuing dependent tool calls. - `debug_run_to_cursor` - Continue execution until reaching specified address - `debug_reset` - Reset emulation. Optional `stop_at_start` stops the debugger before the first instruction (default: the Start Paused setting); the answer has `paused` - `debug_get_status` - Get debug status (paused, at_breakpoint, pc address) ### CPU & Registers - `write_huc6280_register` - Set register value - `get_huc6280_status` - Get complete HuC6280 CPU status (registers, MPR, timer, interrupts, I/O, speed) ### Memory Operations - `list_memory_areas` - List all available memory areas - `read_memory` - Read from specific memory area - `write_memory` - Write to specific memory area - `get_memory_selection` - Get current memory selection range - `select_memory_range` - Select a range of memory addresses - `set_memory_selection_value` - Set all bytes in selection to specified value - `add_memory_bookmark` - Add bookmark in memory area - `remove_memory_bookmark` - Remove memory bookmark - `list_memory_bookmarks` - List all bookmarks in memory area - `add_memory_watch` - Add watch (tracked memory location) - `remove_memory_watch` - Remove memory watch - `list_memory_watches` - List all watches in memory area - `memory_search_capture` - Capture memory snapshot for search comparison - `memory_search` - Search memory with operators (<, >, ==, !=, <=, >=), compare types (previous, value, address), and data types (hex, signed, unsigned) - `memory_find` - Find hex byte sequences (`hex_bytes`) or text (`text`, optional `case_sensitive`) in memory ### Disassembly & Debugging - `get_disassembly` - Get disassembly for specified address range - `add_symbol` - Add symbol (label) at specified address - `remove_symbol` - Remove symbol - `list_symbols` - List all defined symbols - `lookup_symbol_by_name` - Find all exact-name symbol matches - `lookup_symbol_at_address` - Find symbol at bank/address - `add_disassembler_bookmark` - Add bookmark in disassembler - `remove_disassembler_bookmark` - Remove disassembler bookmark - `list_disassembler_bookmarks` - List all disassembler bookmarks - `get_call_stack` - View function call hierarchy - `get_trace_log` - Read trace logger entries (CPU + hardware events) using absolute sequence pagination. Use `set_trace_log` to start or stop the logger - `set_trace_log` - Start or stop trace logging and configure exact event filters and memory or disk storage #### Trace pagination `get_trace_log` returns: - `total_entries`: entries currently retained in the memory ring. - `total_logged`: the next absolute sequence number. It is monotonic for the process lifetime and is not reset by clear, resize, media changes, or save-state loads. - `oldest_sequence`: absolute sequence of the oldest retained entry (`total_logged - total_entries`). - `start`: actual absolute sequence used for this page. - `next_sequence`: absolute sequence to pass as the next `start`. - `count`: number of returned entries. - `overrun`: `true` when a requested `start` had expired and was clamped to `oldest_sequence`. - `lines`: formatted trace entries in sequence order. When `start` is omitted, the latest 100 retained entries are returned. A negative `start` requests that many entries from the retained tail. Positive starts are absolute sequences. `count` defaults to 100 and is capped at 1000. A requested sequence older than `oldest_sequence` starts at the oldest retained entry and sets `overrun` to `true`. A sequence at or beyond `total_logged` returns an empty page with `start` and `next_sequence` equal to the requested value and `overrun` set to `false`. Memory-mode counters shown in the GUI and written by manual export use the same absolute sequence values as MCP. Disk trace files use a separate zero-based entry counter local to each file. #### Trace filters Omitting `filters` enables the safe default of CPU instructions and IRQs. When supplied, `filters` must be non-empty, unique, and contain only these exact values: ```text cpu.instructions cpu.irqs vdc.registers vdc.irqs vdc.dma vdc.sprite_budget vdc.sprite_limit vdc.missed_vblank vce.registers vce.timing input.reads input.writes input.turbolink input.turbolink.writes input.turbolink.drive input.turbolink.samples input.turbolink.cable timer.irqs timer.registers cdrom.irqs cdrom.control cdrom.audio psg.global_lfo psg.frequency psg.channel psg.wave_dda psg.noise adpcm.registers adpcm.dma adpcm.playback adpcm.transfers adpcm.irqs scsi.commands scsi.phases scsi.responses scsi.response_bytes scsi.transfers scsi.problems system.mpr system.mapper system.interrupts ``` `input.turbolink` enables all four TurboLink streams. `writes` records every `$1000` O-port access, `drive` records only changes to the BU5782K pull-low outputs, `samples` records physical LINK1/LINK2 levels and the actual K result with D0-D3, and `cable` records activation/deactivation of the local emulated hardware endpoint. Shared-memory heartbeats and barriers are intentionally not emulation trace events. `vdc.sprite_budget` records one entry per active line with the number of sprites on that line against the 16-sprite limit (32-pixel-wide sprites count as two), flagging lines that hit the limit and how many sprites were dropped. `vdc.sprite_limit` records only the lines that hit the limit. Both are evaluated when the VDC fetches sprites at the end of each line and report the raster line those sprites belong to. `vdc.missed_vblank` detects frames where the game missed VBlank. It watches one CPU logical address, set with `vblank_watch_address` (hex, e.g. `2000`, `0x2000`, or `$2000`), for the access set with `vblank_watch_operation` (`read`, `write`, or `read_write`). Every CPU bus access counts, including opcode fetches and block transfers. At each VDC1 VBlank the frame that just ended is checked, and if the watched access did not happen during it, a `VBLANK MISSED` entry is logged with the watched address, operation, and the number of consecutive missed frames. The first VBlank after starting the logger, changing the watch, resetting, or loading a state only arms the check. Both parameters persist in the configuration and keep their current values when omitted; the response echoes them when `vdc.missed_vblank` is active. The watch costs nothing while this filter is not active. The `system` streams cover TAM/MPR mappings, Street Fighter II mapper latch updates, and HuC6280 interrupt-controller mask/acknowledgement writes. ADPCM lines include playing, pending, half-IRQ, and end-IRQ state bits. #### Trace storage Starting a stopped logger without `output` selects `memory`. Memory capacities are `100K`, `500K`, `1M`, `2M`, and `5M` entries; the persisted default is `100K`. Disk limits are `10MB`, `50MB`, `100MB`, `250MB`, `500MB`, `1GB`, and `unbounded`; the persisted default is `100MB`. Storage changes while tracing is active cleanly stop and restart the logger. Repeating the active storage configuration is idempotent and only updates filters. Stopping preserves retained memory entries; changing memory capacity or starting disk output resets the ring used by that recording. Disk output is flushed before stop, reset, media changes, physical CD-ROM eject/error, save-state loads, and shutdown. Failures are reported in the UI and application log but do not cancel unrelated emulator operations. `output_path` is a directory only, not a filename. Geargrafx creates a unique timestamped UTF-compatible trace filename in that directory. When omitted, the configured default, media, or custom directory policy remains in effect. ### Profiler - `set_profiler` - Start, stop, or reset the function profiler with `action` (`start`, `stop`, `reset`). `start` opens the Profiler debugger window and `stop` closes it. Statistics are only collected while the window is visible (in headless mode, while started), starting on the next frame - `get_profiler_data` - Read profiler results: `collecting`, `window_open`, `total_cycles`, `frame_cycles`, `frames`, `function_count`, and per-function `name`, `symbol`, `bank`, `address`, `type`, `calls`, `calls_per_frame`, `inclusive_cycles`, `inclusive_percent`, `exclusive_cycles`, `exclusive_percent`, `average_cycles`, `min_cycles`, and `max_cycles`. Optional `sort` (`inclusive`, `exclusive`, `calls`, `average`, `max`; highest first), `count` (default 50, max 1000), and `filter` (name or hex address substring) ### Breakpoints - `set_breakpoint` - Set execution, read, or write breakpoint (supports 5 memory areas: rom_ram, vram, palette, huc6270_reg, huc6260_reg) - `set_breakpoint_range` - Set breakpoint for an address range (supports 5 memory areas) - `remove_breakpoint` - Remove breakpoint - `list_breakpoints` - List all breakpoints ### Hardware Status - `get_huc6270_status` - Get VDC status (position, state, control, interrupts) - `get_huc6270_registers` - Get all 20 VDC registers (0x00-0x13), Address Register (AR), and Status Register (SR) - `write_huc6270_register` - Write to a VDC register (0-19) or Address Register (20=AR). Status Register is read-only. Use vdc parameter (1 or 2) for SuperGrafx - `get_huc6260_status` - Get VCE status (position, sync signals, control) - `get_huc6202_status` - Get VPC status (SuperGrafx only) - `get_psg_status` - Get PSG status for all 6 channels - `get_cdrom_status` - Get CD-ROM or LaserActive drive status, including the signed disc-head LBA, sample/frame position, search-burst phase, analog mute/fade counters, SRAM latch, and PD6103A registers/freeze state. Inspection does not advance emulated state. - `list_cdrom_tracks` - List CD-ROM track types and LBA ranges - `get_cdrom_audio_status` - Get CD-ROM audio playback status, or the shared LaserActive transport and mixed analog/digital output status - `get_adpcm_status` - Get ADPCM audio status - `get_arcade_card_status` - Get Arcade Card status - `get_turbolink_status` - Get BU5782K SEL/CLR and pull-low state, the last actual K/line sample with D0-D3 and event ticks, plus shared-memory membership, hardware readiness, pacing, progress, barrier, lease, generation, and recovery diagnostics - `reset_turbolink_metrics` - Reset TurboLink activity, synchronization, wait, and recovery counters ### Sprites - `list_sprites` - List all 64 sprites with position, size, pattern, palette - `get_sprite_image` - Get sprite image as base64 PNG ### Screen Capture - `get_screenshot` - Capture current screen frame as base64 PNG - `start_video_recording` - Start recording video and audio to an AVI file (MJPEG, uncompressed or PNG compressed video, 16-bit PCM audio). Only the resulting `file_path` is returned; the video stays on disk. Optional `file_path` (absolute; if omitted, an automatic name in the configured video recordings directory), `scale` (1-20), `aspect_ratio` (`screen`, `square`, `4:3`, `16:9`, `16:10`, `6:5`), and `quality` (`low`, `medium`, `high`, `lossless`, `lossless_compressed`). `lossless` is uncompressed; `lossless_compressed` stores PNG frames, much smaller but playable only with FFmpeg based players. Given options update the recording settings, same as the GUI menu. `screen` follows the display aspect ratio, which uses square pixels while debugging. When a shader preset is active outside debug mode, the shader output is recorded at the output window size and `scale` and `aspect_ratio` are ignored. Frames are recorded only while the emulator runs, so continue or step execution before stopping - `stop_video_recording` - Stop the active recording and finalize the AVI file. Returns `file_path` and the number of recorded `frames` ### Media & State Management - `get_media_info` - Get loaded ROM/CD info, including native MMI catalog, selected side, format and eject state fields - `list_recent_media` - List the 10 most recent ROM files or CD-ROM images opened by Geargrafx - `load_media` - Load ROM or disc media (.pce, .sgx, .hes, .cue, .chd, .mmi, .zip). Automatically loads .sym symbol file if present. Optional `stop_at_start` as in `debug_reset` - `load_bios` - Load a CD-ROM or LaserActive BIOS. Types: `syscard`, `gameexpress`, `pac_japan`, and `pac_us` - `list_mmi_media` - List the media/sides in the loaded MMI in sequence order - `eject_mmi_media` - Eject the virtual LaserDisc without resetting the machine - `insert_mmi_media` - Insert the selected virtual LaserDisc medium - `select_mmi_media` - Select a zero-based MMI media index while the virtual disc is ejected; indices follow sequence order and do not reset the CPU or RAM - `load_symbols` - Load debug symbols from file (.sym format with 'BANK:ADDRESS LABEL' entries) - `list_save_state_slots` - List all 5 save state slots with information (rom name, timestamp, validity) - `select_save_state_slot` - Select active save state slot (1-5) for save/load operations - `save_state` - Save emulator state to currently selected slot - `load_state` - Load emulator state from currently selected slot - `save_state_file` - Save emulator state to an explicit file path - `load_state_file` - Load emulator state from an explicit file path - `set_fast_forward_speed` - Set fast forward speed multiplier (0: 1.5x, 1: 2x, 2: 2.5x, 3: 3x, 4: Unlimited) - `toggle_fast_forward` - Toggle fast forward mode on/off - `get_rewind_status` - Get rewind buffer status (enabled, snapshots, capacity, buffered seconds) - `rewind_seek` - Seek to a specific rewind snapshot while paused ### Cheats - `list_cheats` - List cheats with index, code, description, enabled, valid and active state - `add_cheat` - Add an enabled cheat: `AAAAAA:VV` or `AAAAAA?CC:VV` at a 21-bit physical address (e.g. `1F0DB1:09`), join codes with `+` - `remove_cheat` - Remove a cheat by index ### Controller Input - `controller_button` - Control a button on a controller (player 1-5). Use action 'press' to hold the button, 'release' to let it go, or 'press_and_release' to simulate a quick tap. Buttons: up, down, left, right, select, run, I, II, III, IV, V, VI. Loading a state or rewinding resyncs input to the host controllers, releasing held buttons; press them again afterwards - `controller_macro` - Run an ordered input macro. Top-level `player` defaults to 1, and each command may override it. Supported commands are `tap`, `press`, `release`, and `wait`; timing is explicit through `wait` frame counts - `get_input_state` - Get effective pressed buttons and current controller input state - `controller_set_type` - Set controller type for a player: standard (2 buttons), avenue_pad_3 (3 buttons), avenue_pad_6 (6 buttons) - `controller_get_type` - Get the current controller type for a player (returns: standard, avenue_pad_3, or avenue_pad_6) - `controller_set_turbo_tap` - Enable or disable Turbo Tap (multitap) for 5-player support ## Available MCP Resources In addition to tools, the MCP server provides documentation resources that AI assistants can access to better understand the PC Engine / TurboGrafx-16 hardware and programming. In Claude Code, type `@` in your prompt to pick a resource, or reference one directly, for example `@geargrafx:geargrafx://hardware/huc6280_cpu`. Codex reads resources through its built-in MCP resource tools, so ask it to read the ones that are relevant. ### Hardware Documentation Resources Complete technical reference documentation for all PC Engine / TurboGrafx-16 hardware components: - **HuC6280 CPU — 8-bit CMOS Microprocessor** (`geargrafx://hardware/huc6280_cpu`) - **HuC6280 Instruction Set Reference** (`geargrafx://hardware/huc6280_instructions`) - **HuC6280 PSG — Programmable Sound Generator** (`geargrafx://hardware/huc6280_psg`) - **HuC6270 VDC — Video Display Controller** (`geargrafx://hardware/huc6270_vdc`) - **HuC6260 VCE — Video Color Encoder** (`geargrafx://hardware/huc6260_vce`) - **HuC6202 VPC — Video Priority Controller** (`geargrafx://hardware/huc6202_vpc`) - **PC Engine Memory Map** (`geargrafx://hardware/memory_map`) ## How MCP Works in Geargrafx - The MCP server runs **alongside** the GUI in a background thread - The emulator GUI remains fully functional (you can play/debug normally while using MCP) - Commands from the AI are queued and executed on the GUI thread - Both GUI and MCP share the same emulator state - Changes made through MCP are instantly reflected in the GUI and vice versa ## Architecture ### STDIO Transport ``` ┌─────────────────┐ ┌──────────────────┐ │ Claude Code / │ stdio │ Geargrafx │ │ Codex │◄──────────────────►│ MCP Server │ │ (AI Client) │ pipes │ (background) │ └─────────────────┘ └──────────────────┘ │ │ └───► Launches ►────────────────────────┘ │ │ Shared State ▼ ┌──────────────────┐ │ Emulator Core │ │ + GUI Window │ └──────────────────┘ ``` ### HTTP Transport ``` ┌─────────────────┐ ┌──────────────────┐ │ Claude Code / │ HTTP (port 7777) │ Geargrafx │ │ Codex │◄──────────────────►│ MCP HTTP Server │ │ (AI Client) │ │ (listener) │ └─────────────────┘ └──────────────────┘ │ │ Shared State ▼ ┌──────────────────┐ │ Emulator Core │ │ + GUI Window │ └──────────────────┘ ```