install_apk
Install APK files from local storage onto Android devices using ADB commands. Specify the file path and optionally target a specific device by serial number.
Instructions
Install an APK file onto the Android device from a local file path.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| local_path | Yes | Local filesystem path to the APK file | |
| device_id | No | Device serial number |
Implementation Reference
- src/adb/app-manager.ts:75-87 (handler)The core function that executes the ADB install command.
export async function installApk(localPath: string, deviceId?: string): Promise<string> { const resolved = await deviceManager.resolveDeviceId(deviceId); validateLocalPath(localPath); const result = await adbExec(['install', '-r', localPath], resolved, 120000); if (result.stdout.includes('Success')) { log.info('APK installed', { localPath, deviceId: resolved }); return `Successfully installed: ${localPath}`; } throw new Error(`APK installation failed: ${result.stdout} ${result.stderr}`); } - src/controllers/app-tools.ts:127-147 (registration)Registration of the install_apk tool within the MCP server.
server.registerTool( 'install_apk', { description: 'Install an APK file onto the Android device from a local file path.', inputSchema: { local_path: z.string().describe('Local filesystem path to the APK file'), device_id: z.string().optional().describe('Device serial number'), }, }, async ({ local_path, device_id }) => { return await metrics.measure('install_apk', device_id || 'default', async () => { const result = await installApk(local_path, device_id); return { content: [{ type: 'text' as const, text: JSON.stringify({ success: true, message: result }, null, 2), }], }; }); } );