press_left
Use this tool to press and hold the LEFT button on a GameBoy emulator for a specified duration in frames, enabling precise control for in-game actions or navigation.
Instructions
Press the LEFT button on the GameBoy
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| duration_frames | No | Number of frames to hold the button |
Implementation Reference
- src/tools.ts:28-35 (handler)Handler logic for the 'press_left' tool (shared with other press_* tools): presses the LEFT button for the specified duration and returns the current screen image.
async ({ duration_frames }): Promise<CallToolResult> => { // Press the button using the service (advances one frame) emulatorService.pressButton(button, duration_frames); // Return the current screen using the service const screen = emulatorService.getScreen(); return { content: [screen] }; } - src/tools.ts:25-27 (schema)Input schema for 'press_left' tool: optional duration_frames (number of frames to hold LEFT button, default 25).
{ duration_frames: z.number().int().positive().optional().default(1).describe('Number of frames to hold the button').default(25) }, - src/tools.ts:20-37 (registration)Dynamic registration of 'press_left' tool (for GameBoyButton.LEFT) along with other press_* tools on the MCP server.
// Register button press tools Object.values(GameBoyButton).forEach(button => { server.tool( `press_${button.toLowerCase()}`, `Press the ${button} button on the GameBoy`, { duration_frames: z.number().int().positive().optional().default(1).describe('Number of frames to hold the button').default(25) }, async ({ duration_frames }): Promise<CallToolResult> => { // Press the button using the service (advances one frame) emulatorService.pressButton(button, duration_frames); // Return the current screen using the service const screen = emulatorService.getScreen(); return { content: [screen] }; } ); }); - src/types.ts:9-18 (helper)GameBoyButton enum defining the LEFT button used to register and identify the 'press_left' tool.
export enum GameBoyButton { UP = 'UP', DOWN = 'DOWN', LEFT = 'LEFT', RIGHT = 'RIGHT', A = 'A', B = 'B', START = 'START', SELECT = 'SELECT' } - src/emulatorService.ts:72-80 (helper)Core pressButton implementation in EmulatorService that handles pressing the LEFT button on the underlying GameBoyEmulator.
pressButton(button: GameBoyButton, durationFrames: number): ImageContent { log.debug(`Pressing button: ${button}`); if (!this.isRomLoaded()) { log.warn('Attempted to press button with no ROM loaded'); throw new Error('No ROM loaded'); } this.emulator.pressButton(button, durationFrames); // This advances one frame return this.getScreen(); }