Skip to main content
Glama

installApp

Install APK files on Android devices via the AutoMobile MCP server. Input the APK file path to execute the installation process for mobile automation tasks.

Instructions

Install an APK file on the device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apkPathYesPath to the APK file to install

Implementation Reference

  • Registers the 'installApp' tool in the ToolRegistry with name, description, input schema, and handler function.
    ToolRegistry.registerDeviceAware( "installApp", "Install an APK file on the device", installAppSchema, installAppHandler );
  • The tool handler function for 'installApp', which instantiates the InstallApp class and executes the installation, handling errors and formatting the response.
    // Install app handler const installAppHandler = async (device: BootedDevice, args: InstallAppArgs) => { try { const installApp = new InstallApp(device); const result = await installApp.execute(args.apkPath); return createJSONToolResponse({ message: `Installed app from ${args.apkPath}`, ...result }); } catch (error) { throw new ActionableError(`Failed to install app: ${error}`); } };
  • Zod schema defining the input parameters for the installApp tool (apkPath: string).
    export const installAppSchema = z.object({ apkPath: z.string().describe("Path to the APK file to install"), });
  • The InstallApp class containing the core logic for installing an APK via ADB, including package extraction, upgrade detection, and installation command execution.
    export class InstallApp { private adb: AdbUtils; /** * Create an InstallApp instance * @param device - Optional device * @param adb - Optional AdbUtils instance for testing */ constructor(device: BootedDevice, adb: AdbUtils | null = null) { this.adb = adb || new AdbUtils(device); } /** * Install an APK file * @param apkPath - Path to the APK file */ async execute(apkPath: string): Promise<{ success: boolean; upgrade: boolean }> { if (!path.isAbsolute(apkPath)) { apkPath = path.resolve(process.cwd(), apkPath); } // Extract package name from APK const packageNameCmd = `dump badging "${apkPath}" | grep "package:" | grep -o "name='[^']*'" | cut -d= -f2 | tr -d "'"`; const packageName = await this.adb.executeCommand(packageNameCmd); // Check if app is already installed const isInstalledCmd = `shell pm list packages -f ${packageName.trim()} | grep -c ${packageName.trim()}`; const isInstalledOutput = await this.adb.executeCommand(isInstalledCmd, undefined, undefined, true); const isInstalled = parseInt(isInstalledOutput.trim(), 10) > 0; const installOutput = await this.adb.executeCommand(`install -r "${apkPath}"`); const success = installOutput.includes("Success"); return { success: success, upgrade: isInstalled && success }; } }

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/zillow/auto-mobile'

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