mobile_list_apps
Retrieve a list of installed applications on a mobile device for automation testing or device management purposes.
Instructions
List all the installed apps on the device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device | Yes | The device identifier to use. Use mobile_list_available_devices to find which devices are available to you. |
Implementation Reference
- src/server.ts:252-264 (registration)Registers the MCP tool 'mobile_list_apps' with Zod input schema (device ID) and a thin handler that delegates to the appropriate Robot.listApps() implementation.tool( "mobile_list_apps", "List Apps", "List all the installed apps on the device", { device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you.") }, async ({ device }) => { const robot = getRobotFromDevice(device); const result = await robot.listApps(); return `Found these apps on device: ${result.map(app => `${app.appName} (${app.packageName})`).join(", ")}`; } );
- src/android.ts:117-130 (handler)AndroidRobot.listApps(): Retrieves list of installed apps with launcher activities using adb shell command.public async listApps(): Promise<InstalledApp[]> { // only apps that have a launcher activity are returned return this.adb("shell", "cmd", "package", "query-activities", "-a", "android.intent.action.MAIN", "-c", "android.intent.category.LAUNCHER") .toString() .split("\n") .map(line => line.trim()) .filter(line => line.startsWith("packageName=")) .map(line => line.substring("packageName=".length)) .filter((value, index, self) => self.indexOf(value) === index) .map(packageName => ({ packageName, appName: packageName, })); }
- src/ios.ts:125-138 (handler)IosRobot.listApps(): Retrieves list of all installed apps using go-ios 'apps --all --list' command.public async listApps(): Promise<InstalledApp[]> { await this.assertTunnelRunning(); const output = await this.ios("apps", "--all", "--list"); return output .split("\n") .map(line => { const [packageName, appName] = line.split(" "); return { packageName, appName, }; }); }
- src/mobile-device.ts:144-150 (handler)MobileDevice.listApps(): Retrieves list of installed apps using mobilecli 'apps list' command via JSON response.public async listApps(): Promise<InstalledApp[]> { const response = JSON.parse(this.runCommand(["apps", "list"])) as InstalledAppsResponse; return response.data.map(app => ({ appName: app.appName || app.packageName, packageName: app.packageName, })) as InstalledApp[]; }
- src/server.ts:142-179 (helper)Helper function to resolve device ID to the correct Robot instance (IosRobot, AndroidRobot, or MobileDevice) for executing listApps() and other methods.const getRobotFromDevice = (deviceId: string): Robot => { // from now on, we must have mobilecli working ensureMobilecliAvailable(); // Check if it's an iOS device const iosManager = new IosManager(); const iosDevices = iosManager.listDevices(); const iosDevice = iosDevices.find(d => d.deviceId === deviceId); if (iosDevice) { return new IosRobot(deviceId); } // Check if it's an Android device const androidManager = new AndroidDeviceManager(); const androidDevices = androidManager.getConnectedDevices(); const androidDevice = androidDevices.find(d => d.deviceId === deviceId); if (androidDevice) { return new AndroidRobot(deviceId); } // Check if it's a simulator (will later replace all other device types as well) const response = mobilecli.getDevices({ platform: "ios", type: "simulator", includeOffline: false, }); if (response.status === "ok" && response.data && response.data.devices) { for (const device of response.data.devices) { if (device.id === deviceId) { return new MobileDevice(deviceId); } } } throw new ActionableError(`Device "${deviceId}" not found. Use the mobile_list_available_devices tool to see available devices.`); };