setActiveDevice
Define the active device ID for targeted mobile automation tasks on Android or iOS platforms using the AutoMobile MCP server, enabling streamlined test execution and operations.
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 main handler function for the setActiveDevice tool. It ensures the specified device is ready using DeviceSessionManager and returns a success message with the device ID.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 defining the input parameters for 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:116-121 (registration)Registration of the setActiveDevice tool with the ToolRegistry, including name, description, schema, and handler.ToolRegistry.register( "setActiveDevice", "Set the active device ID for subsequent operations", setActiveDeviceSchema, setActiveDeviceHandler );
- src/server/utilityTools.ts:43-46 (schema)TypeScript interface for the arguments accepted by the setActiveDevice handler.export interface SetActiveDeviceArgs { deviceId: string; platform: Platform; }