Skip to main content
Glama

android_list_packages

List installed packages on Android devices to identify applications and manage software inventory. 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 primary handler function that processes the android_list_packages tool call, invokes the ADB wrapper's listPackages method, and formats the response as MCP content.
    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)}`); } }
  • Core helper method in ADBWrapper that executes 'adb shell pm list packages', parses the output to extract package names, applies optional filtering, and returns the list of installed packages.
    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; }
  • Tool schema definition including name, description, and input schema for the android_list_packages tool, returned by ListToolsRequestHandler.
    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)
    Dispatch/registration of the android_list_packages tool handler in the CallToolRequestSchema switch statement.
    case 'android_list_packages': return await listPackagesHandler(this.adb, args);
  • TypeScript interface defining the input arguments for the listPackagesHandler.
    interface ListPackagesArgs { filter?: string; deviceSerial?: string; }

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