Skip to main content
Glama

android_list_packages

Retrieve installed packages on an Android device to identify applications, manage software, or troubleshoot issues. Optionally filter results by package name or target specific devices.

Instructions

List installed packages on the Android device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNoOptional filter to search for specific packages (case-insensitive)
deviceSerialNoSpecific device serial number to target (optional)

Implementation Reference

  • The main handler function for the 'android_list_packages' tool. It processes input arguments, calls the ADB wrapper's listPackages method, formats the result into MCP response format, and handles errors.
    export async function listPackagesHandler( adb: ADBWrapper, args: any ): Promise<{ content: Array<{ type: string; text: string }> }> { const { filter, deviceSerial } = args as ListPackagesArgs; try { const packages = await adb.listPackages(filter, deviceSerial); return { content: [ { type: 'text', text: `Found ${packages.length} packages${filter ? ` matching "${filter}"` : ''}:\n${packages.join('\n')}`, }, ], }; } catch (error) { throw new Error(`List packages failed: ${error instanceof Error ? error.message : String(error)}`); } }
  • Tool schema definition for 'android_list_packages', including name, description, and input schema, returned by ListToolsRequest handler.
    { name: 'android_list_packages', description: 'List installed packages on the Android device', inputSchema: { type: 'object', properties: { filter: { type: 'string', description: 'Optional filter to search for specific packages (case-insensitive)', }, deviceSerial: { type: 'string', description: 'Specific device serial number to target (optional)', }, }, }, },
  • src/index.ts:472-473 (registration)
    Registration and dispatch in the CallToolRequest switch statement, mapping 'android_list_packages' to the listPackagesHandler function.
    case 'android_list_packages': return await listPackagesHandler(this.adb, args);
  • TypeScript interface defining the expected input shape for the android_list_packages handler arguments.
    interface ListPackagesArgs { filter?: string; deviceSerial?: string; }
  • Core utility method in ADBWrapper that executes the ADB command 'pm list packages', parses the output to extract package names, and applies optional case-insensitive filtering.
    async listPackages(filter?: string, deviceSerial?: string): Promise<string[]> { const device = await this.getTargetDevice(deviceSerial); const { stdout } = await this.exec(['shell', 'pm', 'list', 'packages'], device); const packages = stdout .split('\n') .map(line => line.replace('package:', '').trim()) .filter(pkg => pkg.length > 0); if (filter) { return packages.filter(pkg => pkg.toLowerCase().includes(filter.toLowerCase())); } return packages; }

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/jduartedj/android-mcp-server'

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