Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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)}`);
      }
    }
  • 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);
  • TypeScript interface defining the expected arguments for the handler (empty object).
    interface GetLatestFrameArgs {
      // No arguments needed
    }
  • Supporting method in ADBWrapper that returns the cached latest frame buffer used by the handler.
    getLatestFrame(): Buffer | null {
      return this.latestFrame;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jduartedj/android-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server