Skip to main content
Glama
zillow
by zillow

startDevice

Start a mobile device with a specified image for automated testing. Use this tool to launch Android or iOS devices by providing device details and target platform.

Instructions

Start a device with the specified device image

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
localDeviceYes
platformYesTarget platform

Implementation Reference

  • Main handler function that executes the startDevice tool logic: creates DeviceUtils instance, starts the device process, waits for readiness, reports progress, and returns device info.
    const startDeviceHandler = async (args: startDeviceArgs, progress?: ProgressCallback) => {
      try {
        const deviceUtils = new DeviceUtils();
        const childProcess = await deviceUtils.startDevice(args.device);
    
        if (progress) {
          await progress(60, 100, "Device started, waiting for readiness...");
        }
    
        // Wait for device to be ready
        const readyDevice = await deviceUtils.waitForDeviceReady(args.device, args.timeoutMs);
    
        if (progress) {
          await progress(100, 100, "Device is ready for use");
        }
    
        return createJSONToolResponse({
          message: `${args.device.platform} '${args.device.name}' started and is ready`,
          name: readyDevice.name,
          processId: childProcess.pid,
          isReady: true,
          deviceId: readyDevice.deviceId,
          source: args.device.source,
          platform: args.device.platform
        });
      } catch (error) {
        throw new ActionableError(`Failed to start ${args.device.platform} device: ${error}`);
      }
    };
  • Zod schema defining the input parameters for the startDevice tool, including device details and platform.
    export const startDeviceSchema = z.object({
      localDevice: z.object({
        name: z.string().describe("The device name to start"),
        deviceId: z.string().optional().describe("The device ID")
      }),
      platform: z.enum(["android", "ios"]).describe("Target platform")
    });
  • Registration of the startDevice tool with ToolRegistry, including name, description, schema, handler, and progress support flag.
    ToolRegistry.register(
      "startDevice",
      "Start a device with the specified device image",
      startDeviceSchema,
      startDeviceHandler,
      true // Supports progress notifications
    );
  • TypeScript interface defining the arguments for the startDevice handler.
    export interface startDeviceArgs {
      device: DeviceInfo;
      timeoutMs?: number;
    }
  • Helper method in DeviceUtils class that spawns the actual device process (emulator or simulator) based on platform.
    async startDevice(
      device: DeviceInfo
    ): Promise<ChildProcess> {
      switch (device.platform) {
        case "android":
          return this.emulator.startEmulator(device.name);
        case "ios":
          return this.simctl.startSimulator(device.name);
        default:
          throw new ActionableError("Unknown platform");
      }
    }

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/zillow/auto-mobile'

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