adb_install
Install APK files on Android devices using ADB commands. Specify the APK path and optional device ID to deploy applications directly from your computer.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apkPath | Yes | Local path to the APK file | |
| device | No | Specific device ID (optional) |
Implementation Reference
- src/index.ts:504-528 (handler)The main handler function that executes the ADB install command with the provided APK path on the specified device, handling errors and logging.async (args: z.infer<typeof AdbInstallSchema>, _extra: RequestHandlerExtra) => { log(LogLevel.INFO, `Installing APK file from path: ${args.apkPath}`); try { // Install the APK using the provided file path const deviceArgs = buildDeviceArgs(args.device); const apkPath = args.apkPath.trim(); if (!apkPath) { throw new Error("APK path must not be empty"); } const result = await executeAdbCommand([...deviceArgs, "install", "-r", apkPath], "Error installing APK"); if (!result.isError) { log(LogLevel.INFO, "APK installed successfully"); } return result; } catch (error) { const errorMsg = error instanceof Error ? error.message : String(error); log(LogLevel.ERROR, `Error installing APK: ${errorMsg}`); return { content: [{ type: "text" as const, text: `Error installing APK: ${errorMsg}` }], isError: true }; } },
- src/index.ts:501-530 (registration)Registers the 'adb_install' tool with the MCP server, specifying the tool name, input schema, handler function, and description.server.tool( "adb_install", AdbInstallSchema.shape, async (args: z.infer<typeof AdbInstallSchema>, _extra: RequestHandlerExtra) => { log(LogLevel.INFO, `Installing APK file from path: ${args.apkPath}`); try { // Install the APK using the provided file path const deviceArgs = buildDeviceArgs(args.device); const apkPath = args.apkPath.trim(); if (!apkPath) { throw new Error("APK path must not be empty"); } const result = await executeAdbCommand([...deviceArgs, "install", "-r", apkPath], "Error installing APK"); if (!result.isError) { log(LogLevel.INFO, "APK installed successfully"); } return result; } catch (error) { const errorMsg = error instanceof Error ? error.message : String(error); log(LogLevel.ERROR, `Error installing APK: ${errorMsg}`); return { content: [{ type: "text" as const, text: `Error installing APK: ${errorMsg}` }], isError: true }; } }, { description: ADB_INSTALL_TOOL_DESCRIPTION } );
- src/types.ts:51-54 (schema)Zod input schema definition for the adb_install tool parameters: apkPath and optional device.export const adbInstallInputSchema = { apkPath: z.string().describe("Local path to the APK file"), device: z.string().optional().describe("Specific device ID (optional)") };
- src/types.ts:104-104 (schema)Creates the full Zod schema object for AdbInstall by wrapping the input schema.export const AdbInstallSchema = z.object(adbInstallInputSchema);
- src/index.ts:105-110 (helper)Tool description string used in the registration of the adb_install tool.const ADB_INSTALL_TOOL_DESCRIPTION = "Installs an Android application (APK) on a connected device or emulator. " + "Use this for deploying applications, testing new builds, or updating existing apps. " + "Provide the local path to the APK file for installation. " + "Automatically handles the installation process, including replacing existing versions. " + "Specify a device ID when working with multiple connected devices.";