native_run_install_app
Install Android APK or iOS app files directly to mobile devices using native-run for development testing and deployment.
Instructions
Install app on device using native-run (works for Android APK & iOS app)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| platform | No | android | |
| appPath | Yes | ||
| deviceId | No |
Implementation Reference
- src/tools/android/native-run.ts:163-196 (handler)The handler function that implements the core logic for the native_run_install_app tool: parses input arguments, checks if native-run is available, constructs the native-run command with appropriate flags, executes the process, handles errors, and returns a structured success response.handler: async (args: any) => { const parsed = NativeRunInstallAppSchema.parse(args); if (!(await isNativeRunAvailable())) { throw new Error('native-run is not installed. Install with: npm install -g native-run'); } const runArgs = [ parsed.platform, '--app', parsed.appPath, '--device' ]; if (parsed.deviceId) { runArgs.push('--target', parsed.deviceId); } const result = await processExecutor.execute('native-run', runArgs); if (result.exitCode !== 0) { throw new Error(`Failed to install app on ${parsed.platform}: ${result.stderr}`); } return { success: true, data: { message: `App installed successfully on ${parsed.platform}`, platform: parsed.platform, appPath: parsed.appPath, deviceId: parsed.deviceId, tool: 'native-run' }, }; }
- Zod validation schema defining the input parameters for the native_run_install_app tool: platform (android/ios), appPath (required), and optional deviceId.const NativeRunInstallAppSchema = z.object({ platform: z.enum(['android', 'ios']).default('android'), appPath: z.string().min(1), deviceId: z.string().optional(), });
- src/tools/android/native-run.ts:142-197 (registration)Registers the native_run_install_app tool in the createNativeRunTools() function's Map, including name, description, inputSchema (JSON Schema equivalent), and reference to the handler function.tools.set('native_run_install_app', { name: 'native_run_install_app', description: 'Install app on device using native-run (works for Android APK & iOS app)', inputSchema: { type: 'object', properties: { platform: { type: 'string', enum: ['android', 'ios'], default: 'android' }, appPath: { type: 'string', minLength: 1 }, deviceId: { type: 'string' } }, required: ['appPath'] }, handler: async (args: any) => { const parsed = NativeRunInstallAppSchema.parse(args); if (!(await isNativeRunAvailable())) { throw new Error('native-run is not installed. Install with: npm install -g native-run'); } const runArgs = [ parsed.platform, '--app', parsed.appPath, '--device' ]; if (parsed.deviceId) { runArgs.push('--target', parsed.deviceId); } const result = await processExecutor.execute('native-run', runArgs); if (result.exitCode !== 0) { throw new Error(`Failed to install app on ${parsed.platform}: ${result.stderr}`); } return { success: true, data: { message: `App installed successfully on ${parsed.platform}`, platform: parsed.platform, appPath: parsed.appPath, deviceId: parsed.deviceId, tool: 'native-run' }, }; } });
- Helper function used by the handler to check if the native-run CLI tool is installed and available in the system PATH.async function isNativeRunAvailable(): Promise<boolean> { try { await processExecutor.execute('native-run', ['--version']); return true; } catch { return false; } }
- src/utils/tool-categories.ts:101-108 (helper)Metadata entry in the global TOOL_REGISTRY categorizing the native_run_install_app tool with its requirements, performance expectations, and safety flags.'native_run_install_app': { name: 'native_run_install_app', category: ToolCategory.ESSENTIAL, platform: 'cross-platform', requiredTools: [RequiredTool.NATIVE_RUN], description: 'Install app using native-run (APK/iOS)', safeForTesting: false, performance: { expectedDuration: 20000, timeout: 120000 }