get_screen
Retrieve the current GameBoy screen frame to monitor or analyze gameplay, advancing the emulator by one frame automatically for precise control.
Instructions
Get the current GameBoy screen (advances one frame)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:72-76 (handler)Inline handler function for the 'get_screen' MCP tool. Advances the emulator by one frame and returns the current screen as ImageContent.async (): Promise<CallToolResult> => { // Advance one frame and get the screen using the service const screen = emulatorService.advanceFrameAndGetScreen(); return { content: [screen] }; }
- src/tools.ts:68-77 (registration)Registration of the 'get_screen' tool using McpServer.tool() method, including description, empty input schema, and handler.server.tool( 'get_screen', 'Get the current GameBoy screen (advances one frame)', // Updated description {}, async (): Promise<CallToolResult> => { // Advance one frame and get the screen using the service const screen = emulatorService.advanceFrameAndGetScreen(); return { content: [screen] }; } );
- src/types.ts:34-36 (schema)TypeScript interface defining the input schema for get_screen tool (no parameters).export interface GetScreenToolSchema { // No parameters needed }
- src/emulatorService.ts:128-136 (helper)Helper method advanceFrameAndGetScreen() called by the tool handler to advance one frame and retrieve the screen image.advanceFrameAndGetScreen(): ImageContent { log.verbose('Advancing one frame and getting screen'); if (!this.isRomLoaded()) { log.warn('Attempted to advance frame with no ROM loaded'); throw new Error('No ROM loaded'); } this.emulator.doFrame(); return this.getScreen(); }
- src/emulatorService.ts:107-121 (helper)Helper method getScreen() that captures the current emulator screen as base64 PNG ImageContent, used by advanceFrameAndGetScreen().getScreen(): ImageContent { log.verbose('Getting current screen'); if (!this.isRomLoaded()) { log.warn('Attempted to get screen with no ROM loaded'); throw new Error('No ROM loaded'); } const screenBase64 = this.emulator.getScreenAsBase64(); const screen: ImageContent = { type: 'image', data: screenBase64, mimeType: 'image/png' }; log.verbose('Screen data retrieved', JSON.stringify({ mimeType: screen.mimeType, dataLength: screen.data.length })); return screen; }