Skip to main content
Glama

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

Implementation Reference

  • 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}`); } };
  • 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") });
  • 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 );
  • TypeScript interface defining the arguments for the setActiveDevice handler, used for type safety.
    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