android_get_latest_frame
Capture the current screen from an Android device via ADB with immediate access and no delay for real-time monitoring or analysis.
Instructions
Get the latest frame from scrcpy stream (instant access, no latency)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers.ts:606-634 (handler)The main handler function for the 'android_get_latest_frame' tool. It retrieves the latest frame buffer from the ADB wrapper's cache and returns it as a base64-encoded H.264 image or an error message if no frame is available.export async function handleGetLatestFrame(adb: ADBWrapper, args: GetLatestFrameArgs): Promise<{ content: Array<{ type: string; text?: string; data?: string; mimeType?: string }> }> { try { const frame = adb.getLatestFrame(); if (!frame) { return { content: [ { type: 'text', text: 'No frame available. Start streaming first with startScrcpyStream.', }, ], }; } // Return frame as base64-encoded image return { content: [ { type: 'image', data: frame.toString('base64'), mimeType: 'image/h264', }, ], }; } catch (error) { throw new Error(`Failed to get latest frame: ${error instanceof Error ? error.message : String(error)}`); } }
- src/index.ts:374-380 (schema)The tool schema definition provided in the ListTools response, specifying the name, description, and empty input schema (no parameters required).name: 'android_get_latest_frame', description: 'Get the latest frame from scrcpy stream (instant access, no latency)', inputSchema: { type: 'object', properties: {}, }, },
- src/index.ts:498-499 (registration)The switch case registration in the CallToolRequestHandler that routes calls to the 'android_get_latest_frame' tool to the handleGetLatestFrame function.case 'android_get_latest_frame': return await handleGetLatestFrame(this.adb, args as any);
- src/handlers.ts:602-604 (schema)TypeScript interface defining the expected arguments for the handler (empty object).interface GetLatestFrameArgs { // No arguments needed }
- src/adb-wrapper.ts:935-937 (helper)Supporting method in ADBWrapper that returns the cached latest frame buffer used by the handler.getLatestFrame(): Buffer | null { return this.latestFrame; }