adb_start_app
Start Android applications on connected devices by specifying package names, enabling automated app launching for testing and management workflows.
Instructions
Start an app on the device
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| packageName | Yes | Package name of the app to start | |
| activityName | No | Activity name (optional) | |
| deviceId | No | Device ID (optional) |
Implementation Reference
- src/tools/app.ts:79-123 (handler)The startApp method in AppTools class implements the core logic for the adb_start_app tool. It checks device connectivity, constructs the appropriate ADB shell command (am start or monkey), executes it via AdbClient, and returns success/error details.
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 ListTools response, defining parameters: packageName (required), activityName and deviceId (optional).
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)Registration and dispatch in the CallToolRequest handler switch statement, mapping 'adb_start_app' calls to this.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)); - src/index.ts:39-39 (registration)Instantiation of AppTools class instance used for app-related tools including startApp.
this.appTools = new AppTools(this.adbClient);