Skip to main content
Glama

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
NameRequiredDescriptionDefault
apkPathYesLocal path to the APK file
deviceNoSpecific device ID (optional)

Implementation Reference

  • 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 } );
  • 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)") };
  • Creates the full Zod schema object for AdbInstall by wrapping the input schema.
    export const AdbInstallSchema = z.object(adbInstallInputSchema);
  • 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.";

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/srmorete/adb-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server