press_start
Simulate pressing the START button on a GameBoy through the MCP GameBoy Server. Specify the duration to hold the button in frames for precise emulator control.
Instructions
Press the START 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 function executed for the 'press_start' tool (shared with other press_ buttons). Presses the START button for the specified duration_frames and returns the current GameBoy screen as an 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 the 'press_start' tool, defining the optional 'duration_frames' parameter using Zod validation.{ 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)Registration code that dynamically creates and registers the 'press_start' tool (and other press_ buttons) using server.tool() for each GameBoyButton.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:24-25 (registration)Call to registerGameBoyTools which includes registration of the 'press_start' tool on the MCP server.// Register GameBoy tools registerGameBoyTools(server, emulatorService); // Pass emulatorService
- src/types.ts:9-18 (helper)GameBoyButton enum defining 'START' which is used to generate the 'press_start' tool name.export enum GameBoyButton { UP = 'UP', DOWN = 'DOWN', LEFT = 'LEFT', RIGHT = 'RIGHT', A = 'A', B = 'B', START = 'START', SELECT = 'SELECT' }