adb_list_apps
Retrieve a list of installed apps on an Android device via Android Debug Bridge (ADB) by specifying the device ID. Useful for remote app management and automation.
Instructions
List installed apps on the device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | No | Device ID (optional) |
Implementation Reference
- src/tools/app.ts:161-204 (handler)The handler function listInstalledApps that executes the ADB command 'shell pm list packages -3' to list third-party installed apps, parses the package names, and returns structured data including success status, list of packages, count, and device ID.async listInstalledApps(deviceId?: string) { try { const connected = await this.adbClient.isDeviceConnected(deviceId); if (!connected) { return { success: false, error: 'Device not connected', message: 'Cannot list apps - device is not connected' }; } const command = 'shell pm list packages -3'; const result = await this.adbClient.executeCommand(command, deviceId); if (!result.success) { return { success: false, error: result.error, message: 'Failed to list installed apps' }; } const packages = result.output .split('\n') .map(line => line.replace('package:', '').trim()) .filter(line => line.length > 0); return { success: true, data: { packages, count: packages.length, deviceId: deviceId || this.adbClient.getDefaultDevice() }, message: `Found ${packages.length} installed apps` }; } catch (error: any) { return { success: false, error: error.message, message: 'Failed to list installed apps' }; } }
- src/index.ts:278-289 (schema)The input schema definition for the adb_list_apps tool, specifying an optional deviceId parameter.name: 'adb_list_apps', description: 'List installed apps on the device', inputSchema: { type: 'object', properties: { deviceId: { type: 'string', description: 'Device ID (optional)', }, }, required: [], },
- src/index.ts:461-462 (registration)The switch case registration that dispatches calls to adb_list_apps to the AppTools.listInstalledApps method.case 'adb_list_apps': return await this.handleToolCall(this.appTools.listInstalledApps(args?.deviceId as string));