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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it 'lists' packages, which implies a read-only operation, but doesn't specify what the output includes (e.g., package names, versions, permissions), whether it requires ADB access or specific permissions, or if there are rate limits. The description is minimal and lacks crucial behavioral details for a tool interacting with a device.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that front-loads the core purpose without any fluff or redundancy. Every word earns its place, making it highly efficient and easy to parse. It's appropriately sized for a simple listing tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (device interaction tool with no annotations and no output schema), the description is incomplete. It doesn't explain the return format (e.g., list of strings, JSON structure), error conditions, or dependencies like ADB setup. For a tool that likely outputs data, the lack of output details is a significant gap, making it inadequate for full contextual understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with both parameters (filter and deviceSerial) well-documented in the schema. The description adds no additional parameter information beyond implying a listing action. According to the rules, with high schema coverage (>80%), the baseline is 3 even with no param info in the description, which fits here.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('installed packages on the Android device'), making the purpose immediately understandable. It distinguishes from siblings like android_execute_command or android_launch_app by focusing on package enumeration rather than execution or interaction. However, it doesn't explicitly differentiate from potential similar tools (e.g., if there were a 'list_system_packages' sibling), so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., device connectivity), exclusions (e.g., not for uninstalled packages), or related tools (e.g., whether android_uiautomator_dump might overlap). Usage is implied from the name and purpose alone, but no explicit context is given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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