Skip to main content
Glama

mgba_write_range

Write up to 4096 bytes of debug-direct memory to a GBA, GB, or GBC emulator at a specified address. Overwrites target memory sequentially with no undo; bytes must be 0-255.

Instructions

PURPOSE: Write a contiguous byte sequence to emulated memory starting at the given system bus address. USAGE: Use whenever you're seeding more than ~4 bytes — one round-trip vs N frame-latency hops compared to looping mgba_write8. Maximum 4096 bytes per call (bridge serialization limit); for larger writes, batch in 4 KiB chunks. Useful for installing cheat tables, patching code blocks, restoring a captured byte window after experiments, and writing big-endian multi-byte values (byteswap them yourself first). For cart save RAM seeding with proper MBC semantics on Game Boy, use mgba_save_state / mgba_load_state instead — those go through the cartridge bus model. BEHAVIOR: DESTRUCTIVE: overwrites N bytes starting at address with no undo. Debug-direct memory write — bypasses MBC/mapper/DMA, see mgba_write8 notes for the cartridge-bus bypass details. Bytes are written sequentially address, address+1, ..., address+N-1. Returns an error if the address is unmapped, address+N crosses an unmapped boundary, the array contains a value outside 0-255, the array length is < 1 or > 4096, or the bridge method is missing. RETURNS: Single line 'Wrote N bytes → ADDR_HEX'.

NOTE: writes use mGBA's debug-direct memory access, which bypasses the cartridge bus model. On Game Boy with an MBC cartridge, this means writes to ROM region (0x0000-0x7FFF) won't trigger MBC bank-switch / RAM-enable commands, and writes to SRAM (0xA000-0xBFFF) hit the underlying buffer regardless of MBC enable state. To seed cartridge SRAM cleanly, use mgba_save_state / mgba_load_state with a pre-prepared state file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesStarting system bus address. Same address-space conventions as the single-width write tools: full 32-bit for GBA (EWRAM 0x02000000, IWRAM 0x03000000), 16-bit for GB/GBC (WRAM 0xC000, SRAM 0xA000). The N bytes [address, address+len) are written. Writes use debug-direct memory access — bypasses MBC; for cart save RAM seeding use mgba_save_state / mgba_load_state instead.
bytesYesByte values to write, one per element (each 0-255). Length 1-4096 (hard cap from the bridge's serialization limit). Written sequentially from `address` in declaration order.
Behavior5/5

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

Extremely detailed: describes destructive nature (overwrites with no undo), bypasses MBC/mapper/DMA, specifics on Game Boy MBC cartridge behavior (writes to ROM don't trigger bank-switch, SRAM writes hit buffer regardless of enable state). Lists all error conditions. Since no annotations provided, description fully carries the burden.

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?

Well-structured with labeled sections (PURPOSE, USAGE, BEHAVIOR, RETURNS, NOTE). Every sentence adds value. Slightly verbose but still efficient given the complexity.

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

Completeness5/5

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

Covers all aspects: purpose, when to use, behavior, parameters, error handling, return value, and important behavioral notes (MBC bypass). No output schema, but description explains the return string format. Complete for a complex tool.

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

Parameters4/5

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

Schema coverage is 100% with good descriptions. The tool description adds extra context (address conventions for GBA vs GB, debug-direct access, sequential writing, bytes 0-255). Adds value beyond schema.

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

Purpose5/5

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

Explicitly states it writes a contiguous byte sequence to emulated memory. Distinguishes from sibling mgba_write8 by noting it's for seeding more than ~4 bytes to avoid multiple round-trips. Lists concrete use cases like installing cheat tables, patching code blocks.

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

Usage Guidelines5/5

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

Clear guidance on when to use (seeding >4 bytes) and when not (for cart save RAM with MBC semantics, use mgba_save_state/mgba_load_state instead). Mentions batch size limitation (4096 bytes) and alternative approach for larger writes.

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/dmang-dev/mcp-mgba'

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