Skip to main content
Glama

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
NameRequiredDescriptionDefault
deviceIdYesThe device ID to set as active
platformYesTarget platform

Implementation Reference

  • 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}`); } };
  • 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") });
  • 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 );
  • TypeScript interface for the arguments accepted by the setActiveDevice handler.
    export interface SetActiveDeviceArgs { deviceId: string; platform: 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