press_a
Simulate pressing the A button on a GameBoy emulator with customizable duration frames, enabling precise control for testing or gameplay scenarios.
Instructions
Press the A 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)MCP tool handler for all 'press_[button]' tools (including 'press_a'), which calls emulatorService.pressButton and returns the current screen as ImageContent.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_[button] tools using Zod validation for optional duration_frames parameter.{ duration_frames: z.number().int().positive().optional().default(1).describe('Number of frames to hold the button').default(25) },
- src/tools.ts:21-37 (registration)Registers 'press_[button]' MCP tools dynamically for each GameBoyButton enum value (including 'press_a' for GameBoyButton.A).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/server/server.ts:25-25 (registration)Top-level call to registerGameBoyTools function, which registers all GameBoy tools including 'press_a'.registerGameBoyTools(server, emulatorService); // Pass emulatorService
- src/types.ts:9-18 (helper)GameBoyButton enum defining the 'A' button used to generate 'press_a' tool name.export enum GameBoyButton { UP = 'UP', DOWN = 'DOWN', LEFT = 'LEFT', RIGHT = 'RIGHT', A = 'A', B = 'B', START = 'START', SELECT = 'SELECT' }