adb_start_app
Launch an application on an Android device by specifying its package name, with optional activity and device ID parameters, using ADB functionality for app management.
Instructions
Start an app on the device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| activityName | No | Activity name (optional) | |
| deviceId | No | Device ID (optional) | |
| packageName | Yes | Package name of the app to start |
Implementation Reference
- src/tools/app.ts:79-122 (handler)The startApp method in AppTools class implements the core logic for starting an Android app using ADB shell commands 'am start' (if activity specified) or 'monkey' (launcher intent).async startApp(packageName: string, activityName?: string, deviceId?: string) { try { const connected = await this.adbClient.isDeviceConnected(deviceId); if (!connected) { return { success: false, error: 'Device not connected', message: 'Cannot start app - device is not connected' }; } let command: string; if (activityName) { command = `shell am start -n ${packageName}/${activityName}`; } else { command = `shell monkey -p ${packageName} -c android.intent.category.LAUNCHER 1`; } const result = await this.adbClient.executeCommand(command, deviceId); if (!result.success) { return { success: false, error: result.error, message: 'Failed to start app' }; } return { success: true, data: { packageName, activityName, deviceId: deviceId || this.adbClient.getDefaultDevice() }, message: `App ${packageName} started successfully` }; } catch (error: any) { return { success: false, error: error.message, message: 'Failed to start app' }; }
- src/index.ts:238-257 (schema)Input schema definition for the adb_start_app tool in the ListToolsRequestSchema handler.name: 'adb_start_app', description: 'Start an app on the device', inputSchema: { type: 'object', properties: { packageName: { type: 'string', description: 'Package name of the app to start', }, activityName: { type: 'string', description: 'Activity name (optional)', }, deviceId: { type: 'string', description: 'Device ID (optional)', }, }, required: ['packageName'], },
- src/index.ts:457-458 (registration)Tool handler registration in the switch statement of the CallToolRequestSchema, delegating to AppTools.startApp method.case 'adb_start_app': return await this.handleToolCall(this.appTools.startApp(args?.packageName as string, args?.activityName as string, args?.deviceId as string));