setActiveDevice
Select a mobile device to target for automation tasks by specifying its ID and platform (Android or iOS).
Instructions
Set the active device ID for subsequent operations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | Yes | The device ID to set as active | |
| platform | Yes | Target platform |
Implementation Reference
- src/server/utilityTools.ts:87-99 (handler)The handler function that executes the setActiveDevice tool logic. It ensures the device is ready using DeviceSessionManager and returns a success response.const setActiveDeviceHandler = async (args: SetActiveDeviceArgs) => { try { await DeviceSessionManager.getInstance().ensureDeviceReady(args.platform, args.deviceId); return createJSONToolResponse({ message: `Active device set to '${args.deviceId}'`, deviceId: args.deviceId, }); } catch (error) { logger.error("Failed to set active device:", error); throw new ActionableError(`Failed to set active device: ${error}`); } };
- src/server/utilityTools.ts:26-29 (schema)Zod schema for validating input parameters of the setActiveDevice tool: deviceId (string) and platform (android/ios).export const setActiveDeviceSchema = z.object({ deviceId: z.string().describe("The device ID to set as active"), platform: z.enum(["android", "ios"]).describe("Target platform") });
- src/server/utilityTools.ts:117-121 (registration)Registration of the setActiveDevice tool in the ToolRegistry, specifying name, description, schema, and handler function."setActiveDevice", "Set the active device ID for subsequent operations", setActiveDeviceSchema, setActiveDeviceHandler );
- src/server/utilityTools.ts:43-46 (schema)TypeScript interface defining the arguments for the setActiveDevice handler, used for type safety.export interface SetActiveDeviceArgs { deviceId: string; platform: Platform; }