Skip to main content
Glama

mgba_dump_entities

Extract entity and actor data from mGBA emulator's WRAM to analyze game objects during gameplay. Specify ROM path and adjust parameters like entity count and memory addresses.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rom_pathYesPath to the ROM file
entity_baseNoBase address of entity array (default: 0xC200)
entity_sizeNoSize of each entity in bytes (default: 24)
entity_countNoNumber of entities to dump (default: 10)
savestate_pathNoOptional savestate to load
framesNoFrames to run before dumping (default: 60)

Implementation Reference

  • Core handler: MGBAEmulator.dump_entities generates and executes a Lua script to dump entity bytes from WRAM starting at entity_base, for entity_count entities each of entity_size bytes, after running specified frames, and captures screenshot.
        def dump_entities(
            self,
            rom_path: str,
            entity_base: int = 0xC200,
            entity_size: int = 24,
            entity_count: int = 10,
            savestate_path: Optional[str] = None,
            frames_before_dump: int = 60,
        ) -> EmulatorResult:
            """Dump entity data from WRAM."""
            lua_script = f"""
    local frame = 0
    
    callbacks:add("frame", function()
        frame = frame + 1
        if frame >= {frames_before_dump} then
            local f = io.open("output.json", "w")
            if f then
                f:write('{{"boss_flag":' .. emu:read8(0xFFBF) .. ',"entities":[')
                for ent = 0, {entity_count - 1} do
                    local base = {entity_base} + ent * {entity_size}
                    if ent > 0 then f:write(',') end
                    f:write('{{"index":' .. ent .. ',"address":' .. base .. ',"bytes":[')
                    for i = 0, {entity_size - 1} do
                        if i > 0 then f:write(',') end
                        f:write(tostring(emu:read8(base + i)))
                    end
                    f:write(']}}')
                end
                f:write(']}}')
                f:close()
            end
            emu:screenshot("screenshot.png")
            -- Write DONE marker
            local done = io.open("DONE", "w")
            if done then done:write("OK"); done:close() end
        end
    end)
    """
            return self._run_with_lua(rom_path, lua_script, savestate_path)
  • Input schema defining parameters for the mgba_dump_entities tool, including rom_path (required), entity_base, entity_size, entity_count, savestate_path, and frames.
    inputSchema={
        "type": "object",
        "properties": {
            "rom_path": {
                "type": "string",
                "description": "Path to the ROM file",
            },
            "entity_base": {
                "type": "integer",
                "description": "Base address of entity array (default: 0xC200)",
                "default": 49664,
            },
            "entity_size": {
                "type": "integer",
                "description": "Size of each entity in bytes (default: 24)",
                "default": 24,
            },
            "entity_count": {
                "type": "integer",
                "description": "Number of entities to dump (default: 10)",
                "default": 10,
            },
            "savestate_path": {
                "type": "string",
                "description": "Optional savestate to load",
            },
            "frames": {
                "type": "integer",
                "description": "Frames to run before dumping (default: 60)",
                "default": 60,
            },
        },
        "required": ["rom_path"],
    },
  • Registration of the mgba_dump_entities tool in the list_tools() function, including name, description, and inputSchema.
    Tool(
        name="mgba_dump_entities",
        description="Dump entity/actor data from WRAM - useful for analyzing game objects",
        inputSchema={
            "type": "object",
            "properties": {
                "rom_path": {
                    "type": "string",
                    "description": "Path to the ROM file",
                },
                "entity_base": {
                    "type": "integer",
                    "description": "Base address of entity array (default: 0xC200)",
                    "default": 49664,
                },
                "entity_size": {
                    "type": "integer",
                    "description": "Size of each entity in bytes (default: 24)",
                    "default": 24,
                },
                "entity_count": {
                    "type": "integer",
                    "description": "Number of entities to dump (default: 10)",
                    "default": 10,
                },
                "savestate_path": {
                    "type": "string",
                    "description": "Optional savestate to load",
                },
                "frames": {
                    "type": "integer",
                    "description": "Frames to run before dumping (default: 60)",
                    "default": 60,
                },
            },
            "required": ["rom_path"],
        },
    ),
  • Server-side handler in call_tool that invokes emu.dump_entities with parsed arguments, formats the entity dump output as text (boss flag and hex dumps of non-zero entities), adds screenshot if available, or error message.
    elif name == "mgba_dump_entities":
        result = emu.dump_entities(
            rom_path=arguments["rom_path"],
            entity_base=arguments.get("entity_base", 0xC200),
            entity_size=arguments.get("entity_size", 24),
            entity_count=arguments.get("entity_count", 10),
            savestate_path=arguments.get("savestate_path"),
            frames_before_dump=arguments.get("frames", 60),
        )
    
        if result.success and result.data:
            lines = [f"Boss flag: 0x{result.data['boss_flag']:02X}"]
            lines.append("\nEntity Data:")
            for ent in result.data["entities"]:
                bytes_data = ent["bytes"]
                # Check if entity has any non-zero data
                if any(b != 0 for b in bytes_data):
                    hex_str = " ".join(f"{b:02X}" for b in bytes_data[:16])
                    lines.append(f"  Entity {ent['index']} (0x{ent['address']:04X}): {hex_str}...")
            result_content.append(TextContent(type="text", text="\n".join(lines)))
            if result.screenshot:
                result_content.append(ImageContent(
                    type="image",
                    data=base64.b64encode(result.screenshot).decode(),
                    mimeType="image/png",
                ))
        else:
            result_content.append(TextContent(type="text", text=f"Error: {result.error}"))
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions dumping data from WRAM, which implies a read operation, but doesn't clarify if this is safe (non-destructive), requires specific game states, or has side effects like loading a savestate. The description lacks details on output format, error handling, or performance considerations, which are critical for a tool with multiple parameters and no output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded with the core purpose in the first clause. It consists of two short sentences that are efficient and avoid redundancy. However, it could be slightly more structured by explicitly stating the tool's role relative to siblings or including key behavioral notes, but it earns a high score for being direct and waste-free.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (6 parameters, no annotations, no output schema), the description is incomplete. It doesn't cover behavioral aspects like safety, output format, or error conditions, which are essential for an agent to use it correctly. While the schema handles parameter documentation, the lack of annotations and output schema means the description should compensate more by explaining what the tool returns or how it behaves, which it fails to do adequately.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, meaning all parameters are documented in the input schema with descriptions and defaults. The description adds minimal value beyond this, as it doesn't explain parameter interactions (e.g., how 'savestate_path' or 'frames' affect the dump) or provide usage examples. With high schema coverage, the baseline score is 3, reflecting adequate but not enhanced parameter understanding from the description alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Dump entity/actor data from WRAM' with the goal of 'analyzing game objects'. It specifies the verb ('dump'), resource ('entity/actor data'), and source ('WRAM'), making it more specific than just the tool name. However, it doesn't explicitly differentiate from sibling tools like mgba_dump_oam or mgba_read_memory, which likely dump different types of data or from different memory regions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal usage guidance with 'useful for analyzing game objects', which implies a context but doesn't specify when to use this tool versus alternatives. There's no mention of when not to use it, prerequisites, or comparisons to sibling tools like mgba_dump_oam (which might dump sprite data) or mgba_read_memory (which might read arbitrary memory). This leaves the agent without clear direction on tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/struktured-labs/mgba-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server