Skip to main content
Glama
dmang-dev

mcp-retroarch

retroarch_read_ram

Read memory from libretro cores that do not advertise a memory map, using the CHEEVOS address space as a fallback.

Instructions

Read memory via the CHEEVOS (achievements) address space. Use this if retroarch_read_memory reports 'no memory map defined' — some libretro cores don't advertise a memory map but DO support the older CHEEVOS read API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes
lengthYes

Implementation Reference

  • src/tools.ts:72-83 (registration)
    Tool registration entry for retroarch_read_ram, defined in the TOOLS array with its description (CHEEVOS address space) and input schema requiring address (integer) and length (integer, 1-4096).
    {
      name: "retroarch_read_ram",
      description: "Read memory via the CHEEVOS (achievements) address space. Use this if `retroarch_read_memory` reports 'no memory map defined' — some libretro cores don't advertise a memory map but DO support the older CHEEVOS read API.",
      inputSchema: {
        type: "object",
        required: ["address", "length"],
        properties: {
          address: { type: "integer" },
          length:  { type: "integer", minimum: 1, maximum: 4096 },
        },
      },
    },
  • Handler for retroarch_read_ram in the CallToolRequestSchema switch. Calls ra.readRam() on the RetroArchClient instance, formats the returned bytes as hex, and returns them with a CHEEVOS label.
    case "retroarch_read_ram": {
      const bytes = await ra.readRam(p.address as number, p.length as number);
      const hex = Array.from(bytes).map((b) => b.toString(16).padStart(2, "0").toUpperCase()).join(" ");
      return ok(`${addrHex(p.address as number)} [${bytes.length} bytes, CHEEVOS]:\n${hex}`);
    }
  • RetroArchClient.readRam() — the underlying helper that sends the READ_CORE_RAM command over UDP to RetroArch's NCI, then parses the response via parseMemoryReply().
    async readRam(addr: number, length: number): Promise<Uint8Array> {
      if (length <= 0)   throw new Error("length must be positive");
      if (length > 4096) throw new Error("length exceeds 4096 byte limit");
      const cmd = `READ_CORE_RAM 0x${addr.toString(16)} ${length}`;
      const r = (await this.query(cmd)).toString().trim();
      return parseMemoryReply(r, "READ_CORE_RAM", length);
    }
  • parseMemoryReply — shared helper used by readRam() to parse the READ_CORE_RAM UDP response. Handles success (hex bytes), failure (-1 error), and malformed data.
    function parseMemoryReply(reply: string, expectedCmd: string, expectedLen: number): Uint8Array {
      const tokens = reply.split(/\s+/);
      if (tokens[0] !== expectedCmd) {
        throw new Error(`unexpected reply prefix (got "${tokens[0]}", expected "${expectedCmd}")`);
      }
      const tail = tokens.slice(2);
      if (tail.length === 0) {
        throw new Error(`${expectedCmd} returned no bytes`);
      }
      // Failure shape: "<cmd> <addr> -1 <error_msg>"
      if (tail[0] === "-1") {
        const err = tail.slice(1).join(" ") || "(no error message)";
        throw new Error(`${expectedCmd} failed: ${err}`);
      }
      const out = new Uint8Array(tail.length);
      for (let i = 0; i < tail.length; i++) {
        const v = parseInt(tail[i], 16);
        if (Number.isNaN(v) || v < 0 || v > 255) {
          throw new Error(`${expectedCmd}: malformed byte at index ${i}: "${tail[i]}"`);
        }
        out[i] = v;
      }
      if (out.length !== expectedLen) {
        // Not strictly an error — RetroArch may clamp at memory-region boundaries.
        // Caller can decide what to do with a short read.
      }
      return out;
    }
Behavior2/5

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

No annotations are present, so the description must cover behavioral traits. It only explains the alternative read path but does not disclose any side effects, error handling, return format, or whether the operation is safe/read-only. For a memory read tool, this is insufficient.

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

Conciseness5/5

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

The description is two sentences long, front-loads the purpose, and immediately provides the key usage context. No wasted words.

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?

The tool reads arbitrary memory, but the description omits crucial context such as return value format (raw bytes? hex?), valid address ranges, behavior on invalid addresses, and potential side effects. Given no output schema, more detail is needed for safe usage.

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

Parameters1/5

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

Schema description coverage is 0%, and the description does not explain what the 'address' and 'length' parameters mean, their valid ranges, or format. This is a critical gap for correct invocation.

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?

The description clearly states the tool reads memory using the CHEEVOS address space and explicitly distinguishes it from the sibling tool retroarch_read_memory, which uses the memory map. The verb 'read memory' and resource 'CHEEVOS address space' are specific.

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?

The description gives explicit guidance on when to use this tool: 'Use this if retroarch_read_memory reports no memory map defined'. It explains the underlying reason (some cores don't advertise a map but support CHEEVOS API), providing clear context for choosing between siblings.

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-retroarch'

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