Skip to main content
Glama

mgba-mcp

MCP (Model Context Protocol) server for mGBA emulator - enables programmatic control of Game Boy, Game Boy Color, and Game Boy Advance emulation.

Features

  • Headless execution - Runs via xvfb for automated testing

  • Screenshot capture - Get PNG screenshots at any frame

  • Memory reading - Read individual addresses or memory ranges

  • OAM dumping - Dump all 40 sprite entries with position, tile, flags, and palette

  • Entity dumping - Read game entity/actor data from WRAM

  • Custom Lua scripts - Execute arbitrary Lua code in the emulator

  • Savestate support - Load savestates for reproducible testing

Related MCP server: mcp-mgba

Installation

# Install with uv
uv pip install -e .

# Or with pip
pip install -e .

Requirements

  • Python 3.11+

  • mGBA (mgba-qt) installed and in PATH

  • xvfb-run (for headless operation on Linux)

MCP Tools

mgba_run

Run a ROM for a specified number of frames and capture a screenshot.

{
  "rom_path": "/path/to/game.gb",
  "frames": 120,
  "savestate_path": "/path/to/save.ss0"
}

mgba_read_memory

Read memory at specified addresses.

{
  "rom_path": "/path/to/game.gb",
  "addresses": [49664, 65471],
  "frames": 60
}

mgba_read_range

Read a contiguous range of memory.

{
  "rom_path": "/path/to/game.gb",
  "start_address": 49664,
  "length": 256,
  "frames": 60
}

mgba_dump_oam

Dump OAM (Object Attribute Memory) sprite data.

{
  "rom_path": "/path/to/game.gb",
  "savestate_path": "/path/to/save.ss0",
  "frames": 60
}

mgba_dump_entities

Dump entity/actor data from WRAM.

{
  "rom_path": "/path/to/game.gb",
  "entity_base": 49664,
  "entity_size": 24,
  "entity_count": 10,
  "frames": 60
}

mgba_run_lua

Execute a custom Lua script in the emulator.

{
  "rom_path": "/path/to/game.gb",
  "script": "callbacks:add('frame', function() if emu:currentFrame() > 60 then emu:screenshot('screenshot.png'); emu:quit() end end)",
  "timeout": 30
}

Claude Code Integration

Add to your Claude Code MCP settings:

{
  "mcpServers": {
    "mgba": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/mgba-mcp", "mgba-mcp"]
    }
  }
}

Usage Example

Once configured, Claude Code can use commands like:

Use mgba_dump_oam to check sprite palettes in rom/working/penta_dragon_dx_FIXED.gb
Use mgba_read_range to dump entity data at 0xC200 for 256 bytes

Memory Addresses (Game Boy)

Common memory regions:

  • 0x8000-0x9FFF - VRAM (tile data)

  • 0xC000-0xDFFF - WRAM (work RAM)

  • 0xFE00-0xFE9F - OAM (sprite attributes)

  • 0xFF00-0xFF7F - I/O registers

  • 0xFF80-0xFFFE - HRAM (high RAM)

License

MIT

Available Tools

6 tools
mgba_dump_entitiesC

Dump entity/actor data from WRAM - useful for analyzing game objects

Inputs: rom_path (required), entity_base, entity_size, entity_count, +2 more.

mgba_dump_oamB

Dump OAM (Object Attribute Memory) sprite data - shows all 40 sprites with position, tile, flags, and palette

Inputs: rom_path (required), savestate_path, frames.

mgba_read_memoryC

Read memory at specified addresses after running for some frames

Inputs: rom_path (required), addresses (required), savestate_path, frames.

mgba_read_rangeC

Read a contiguous range of memory addresses

Inputs: rom_path (required), start_address (required), length (required), savestate_path, +1 more.

mgba_runA

Run a GB/GBC/GBA ROM for a specified number of frames and capture a screenshot

Inputs: rom_path (required), frames, savestate_path.

mgba_run_luaA

Run a custom Lua script in the emulator. The script can use emu:read8(), emu:write8(), emu:screenshot(), callbacks:add(), etc.

Inputs: rom_path (required), script (required), savestate_path, timeout.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap: dumping entity data, dumping sprite data, reading specific memory addresses, reading memory ranges, running the emulator, and running Lua scripts. The descriptions make it easy to differentiate between them, eliminating any ambiguity.

    Naming Consistency5/5

    All tools follow a consistent 'mgba_verb_noun' pattern (e.g., mgba_dump_entities, mgba_read_memory, mgba_run_lua). This uniformity makes the tool set predictable and easy to navigate, with no deviations in naming style.

    Tool Count5/5

    With 6 tools, the set is well-scoped for an emulator debugging server, covering core operations like memory access, emulation control, and scripting. Each tool earns its place without feeling excessive or insufficient for the domain.

    Completeness4/5

    The tools provide strong coverage for emulator interaction, including memory inspection, execution control, and custom scripting. A minor gap exists in write operations (e.g., no mgba_write_memory), but agents can work around this using mgba_run_lua for modifications.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to play Pokemon Fire Red through the mGBA emulator by providing tools for button inputs and screenshots. It allows for direct reading of real-time game state from RAM, including party information, player location, and battle status.
      10
      3
      -
    • A
      license
      A
      quality
      B
      maintenance
      MCP server for the mGBA Game Boy Advance emulator. Read and write GBA memory, inject button presses, take screenshots, save/load state, and step the emulator through a Lua bridge.
      18
      40 npm
      7
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for the mGBA Game Boy/GBA emulator, enabling full emulator control, memory access, debugging, and screenshot capture through natural language.
      5
      MIT