Skip to main content
Glama
zillow
by zillow

killDevice

Stop a running mobile device by specifying its name, ID, and platform to terminate processes and free resources.

Instructions

Kill a running device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceYes

Implementation Reference

  • The main handler function for the killDevice tool that instantiates DeviceUtils and calls its killDevice method.
    const killDeviceHandler = async (args: KillDeviceArgs) => {
      try {
        const deviceUtils = new DeviceUtils();
        await deviceUtils.killDevice(args.device);
        return createJSONToolResponse({
          message: `${args.device.platform} '${args.device.name}' shutdown successfully`,
          udid: args.device.name,
          name: args.device.name,
          platform: args.device.platform
        });
      } catch (error) {
        throw new ActionableError(`Failed to kill ${args.device.platform} device: ${error}`);
      }
    };
  • Zod schema defining the input parameters for the killDevice tool.
    export const killDeviceSchema = z.object({
      device: z.object({
        name: z.string().describe("The device image name to kill"),
        deviceId: z.string().describe("The device unique ID"),
        platform: z.enum(["android", "ios"]).describe("Target platform")
      })
    });
  • Registration of the killDevice tool with ToolRegistry, including name, description, schema, and handler.
    ToolRegistry.register(
      "killDevice",
      "Kill a running device",
      killDeviceSchema,
      killDeviceHandler
    );
  • DeviceUtils.killDevice method that routes to platform-specific killers (AndroidEmulator for android, Simctl for iOS).
    async killDevice(
      device: BootedDevice
    ): Promise<void> {
      switch (device.platform) {
        case "android":
          return this.emulator.killDevice(device);
        case "ios":
          return this.simctl.killSimulator(device);
      }
    }
  • Core Android-specific implementation that uses ADB to execute 'emu kill' on the target emulator device.
    async killDevice(device: BootedDevice): Promise<void> {
      const runningEmulators = await this.getBootedDevices();
      const emulator = runningEmulators.find(emu => emu.deviceId === device.deviceId);
    
      if (!emulator || !emulator.deviceId) {
        throw new ActionableError(`Emulator '${device.name}' is not running`);
      }
    
      // Use ADB to stop the emulator
      const adb = new AdbUtils(emulator);
      await adb.executeCommand("emu kill");
    
      logger.info(`Killed emulator '${device.name}'`);
    }

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