android_launch_app
Launch Android applications by specifying their package name, enabling quick app access and testing on connected devices through automated execution.
Instructions
Launch an Android app by package name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| packageName | Yes | Package name of the app to launch (e.g., com.example.app) | |
| deviceSerial | No | Specific device serial number to target (optional) |
Implementation Reference
- src/handlers.ts:203-230 (handler)The primary handler function for the 'android_launch_app' tool. Validates input arguments and calls the ADB wrapper to launch the app, returning success or error message./** * Handle launch app tool call */ export async function launchAppHandler( adb: ADBWrapper, args: any ): Promise<{ content: Array<{ type: string; text: string }> }> { const { packageName, deviceSerial } = args as LaunchAppArgs; if (!packageName || typeof packageName !== 'string') { throw new Error('Invalid package name: packageName must be a non-empty string'); } try { await adb.launchApp(packageName, deviceSerial); return { content: [ { type: 'text', text: `Successfully launched app: ${packageName}`, }, ], }; } catch (error) { throw new Error(`Launch app failed: ${error instanceof Error ? error.message : String(error)}`); } }
- src/adb-wrapper.ts:361-367 (helper)Core implementation in ADBWrapper that executes the ADB shell monkey command to launch the specified Android app package using the LAUNCHER intent.* Launch an app by package name */ async launchApp(packageName: string, deviceSerial?: string): Promise<void> { const device = await this.getTargetDevice(deviceSerial); await this.exec(['shell', 'monkey', '-p', packageName, '-c', 'android.intent.category.LAUNCHER', '1'], device); }
- src/index.ts:120-137 (schema)Tool schema definition including name, description, and input schema (packageName required, deviceSerial optional) provided in the ListTools response.{ name: 'android_launch_app', description: 'Launch an Android app by package name', inputSchema: { type: 'object', properties: { packageName: { type: 'string', description: 'Package name of the app to launch (e.g., com.example.app)', }, deviceSerial: { type: 'string', description: 'Specific device serial number to target (optional)', }, }, required: ['packageName'], }, },
- src/index.ts:470-471 (registration)Tool dispatch registration in the switch statement of the CallToolRequestSchema handler, mapping the tool name to its handler function.case 'android_launch_app': return await launchAppHandler(this.adb, args);
- src/handlers.ts:24-27 (schema)TypeScript interface defining the expected arguments for the launchAppHandler, matching the MCP input schema.interface LaunchAppArgs { packageName: string; deviceSerial?: string; }