retroarch_screenshot
Take a screenshot of the current RetroArch gameplay. It saves to your configured screenshot directory and returns immediately.
Instructions
Capture a screenshot of the current display. RetroArch saves it to its configured screenshot directory (which the NCI doesn't report — check RetroArch's settings). Fire-and-forget; returns immediately.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:230-230 (handler)The tool handler for 'retroarch_screenshot': calls ra.screenshot() and returns a success message.
case "retroarch_screenshot": await ra.screenshot(); return ok("Screenshot saved to RetroArch's configured screenshot directory"); - src/tools.ts:117-121 (registration)Tool schema/registration for 'retroarch_screenshot' in the TOOLS array, with name, description, and empty inputSchema.
{ name: "retroarch_screenshot", description: "Capture a screenshot of the current display. RetroArch saves it to its configured screenshot directory (which the NCI doesn't report — check RetroArch's settings). Fire-and-forget; returns immediately.", inputSchema: { type: "object", properties: {} }, }, - src/retroarch.ts:194-194 (helper)The RetroArchClient.screenshot() method — sends 'SCREENSHOT' command over UDP via the fire-and-forget send() helper.
async screenshot(): Promise<void> { await this.send("SCREENSHOT"); } - src/retroarch.ts:78-86 (helper)The send() method used by screenshot() — a fire-and-forget UDP datagram send to RetroArch's NCI.
/** Fire-and-forget send. Use for hotkey-style commands (PAUSE_TOGGLE, etc.). */ async send(command: string): Promise<void> { if (!this.socket) await this.connect(); return new Promise((resolve, reject) => { this.socket!.send(command, this.port, this.host, (err) => err ? reject(err) : resolve(), ); }); } - src/tools.ts:176-246 (registration)The registerTools function that wires up ListToolsRequestSchema and CallToolRequestSchema handlers, including the switch case for retroarch_screenshot.
export function registerTools(server: Server, ra: RetroArchClient): void { server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS })); server.setRequestHandler(CallToolRequestSchema, async (req) => { const { name, arguments: args = {} } = req.params; const p = args as Record<string, unknown>; switch (name) { case "retroarch_ping": { const v = await ra.getVersion(); return ok(`OK — RetroArch ${v}`); } case "retroarch_get_status": { const s = await ra.getStatus(); if (s.state === "contentless") return ok("No content loaded"); return ok( `State: ${s.state}\n` + `System: ${s.system}\n` + `Game: ${s.game}\n` + `CRC32: ${s.crc32 ?? "(none reported)"}`, ); } case "retroarch_get_config": { const v = await ra.getConfigParam(p.name as string); return ok(`${p.name} = ${v}`); } case "retroarch_read_memory": { const bytes = await ra.readMemory(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]:\n${hex}`); } case "retroarch_write_memory": { const n = await ra.writeMemory(p.address as number, p.bytes as number[]); return ok(`Wrote ${n} bytes → ${addrHex(p.address as number)}`); } 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}`); } case "retroarch_write_ram": { await ra.writeRam(p.address as number, p.bytes as number[]); return ok(`Wrote ${(p.bytes as number[]).length} bytes → ${addrHex(p.address as number)} (CHEEVOS, no ack)`); } case "retroarch_pause_toggle": await ra.pauseToggle(); return ok("Pause toggled"); case "retroarch_frame_advance": await ra.frameAdvance(); return ok("Advanced one frame"); case "retroarch_reset": await ra.reset(); return ok("Game reset"); case "retroarch_screenshot": await ra.screenshot(); return ok("Screenshot saved to RetroArch's configured screenshot directory"); case "retroarch_show_message": { await ra.showMessage(p.message as string); return ok(`Showed: ${p.message}`); } case "retroarch_save_state_current": await ra.saveStateCurrent(); return ok("Saved to current slot"); case "retroarch_load_state_current": await ra.loadStateCurrent(); return ok("Loaded from current slot"); case "retroarch_load_state_slot": await ra.loadStateSlot(p.slot as number); return ok(`Loaded from slot ${p.slot}`); case "retroarch_state_slot_plus": await ra.stateSlotPlus(); return ok("Incremented current slot"); case "retroarch_state_slot_minus": await ra.stateSlotMinus(); return ok("Decremented current slot"); default: throw new Error(`Unknown tool: ${name}`); } }); }