Skip to main content
Glama

android_list_devices

List connected Android devices and emulators to manage development environments, using ADB or native-run for detection.

Instructions

List connected Android devices and emulators (supports ADB fallback to native-run)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that lists connected Android devices and emulators by running 'adb devices -l' via fallback system, parsing the output to extract detailed device information including serial, state, product, model, device type, and transport ID, then returning structured data with counts and fallback info.
    handler: async () => {
      const fallbackResult = await fallbackManager.executeAdbWithFallback(
        ['devices', '-l'],
        { platform: 'android' }
      );
    
      if (!fallbackResult.success) {
        throw new Error(fallbackResult.error || 'Failed to list devices');
      }
    
      const result = fallbackResult.data;
    
      // Parse adb devices output
      const devices = [];
      const lines = result.stdout.split('\n').slice(1); // Skip header
    
      for (const line of lines) {
        const trimmed = line.trim();
        if (trimmed && !trimmed.startsWith('*')) {
          const parts = trimmed.split(/\s+/);
          if (parts.length >= 2) {
            const device = {
              serial: parts[0],
              state: parts[1],
              product: '',
              model: '',
              device: '',
              transport_id: '',
            };
    
            // Parse additional info
            for (let i = 2; i < parts.length; i++) {
              const part = parts[i];
              if (part && part.startsWith('product:')) {
                device.product = part.split(':')[1] || '';
              } else if (part && part.startsWith('model:')) {
                device.model = part.split(':')[1] || '';
              } else if (part && part.startsWith('device:')) {
                device.device = part.split(':')[1] || '';
              } else if (part && part.startsWith('transport_id:')) {
                device.transport_id = part.split(':')[1] || '';
              }
            }
    
            devices.push(device);
          }
        }
      }
    
      return {
        success: true,
        data: {
          devices,
          totalCount: devices.length,
          onlineCount: devices.filter(d => d.state === 'device').length,
          fallbackInfo: fallbackResult.usedFallback ? {
            usedFallback: true,
            fallbackTool: fallbackResult.fallbackTool,
            message: fallbackResult.message
          } : undefined
        },
      };
    }
  • Registration of the 'android_list_devices' tool within createAndroidTools function, including name, description, empty input schema (no parameters required), and reference to the handler function.
    tools.set('android_list_devices', {
      name: 'android_list_devices',
      description: 'List connected Android devices and emulators (supports ADB fallback to native-run)',
      inputSchema: {
        type: 'object',
        properties: {},
        required: []
      },
      handler: async () => {
        const fallbackResult = await fallbackManager.executeAdbWithFallback(
          ['devices', '-l'],
          { platform: 'android' }
        );
    
        if (!fallbackResult.success) {
          throw new Error(fallbackResult.error || 'Failed to list devices');
        }
    
        const result = fallbackResult.data;
    
        // Parse adb devices output
        const devices = [];
        const lines = result.stdout.split('\n').slice(1); // Skip header
    
        for (const line of lines) {
          const trimmed = line.trim();
          if (trimmed && !trimmed.startsWith('*')) {
            const parts = trimmed.split(/\s+/);
            if (parts.length >= 2) {
              const device = {
                serial: parts[0],
                state: parts[1],
                product: '',
                model: '',
                device: '',
                transport_id: '',
              };
    
              // Parse additional info
              for (let i = 2; i < parts.length; i++) {
                const part = parts[i];
                if (part && part.startsWith('product:')) {
                  device.product = part.split(':')[1] || '';
                } else if (part && part.startsWith('model:')) {
                  device.model = part.split(':')[1] || '';
                } else if (part && part.startsWith('device:')) {
                  device.device = part.split(':')[1] || '';
                } else if (part && part.startsWith('transport_id:')) {
                  device.transport_id = part.split(':')[1] || '';
                }
              }
    
              devices.push(device);
            }
          }
        }
    
        return {
          success: true,
          data: {
            devices,
            totalCount: devices.length,
            onlineCount: devices.filter(d => d.state === 'device').length,
            fallbackInfo: fallbackResult.usedFallback ? {
              usedFallback: true,
              fallbackTool: fallbackResult.fallbackTool,
              message: fallbackResult.message
            } : undefined
          },
        };
      }
    });
  • FallbackManager.executeAdbWithFallback helper method called by the handler. Executes ADB commands with automatic fallback to native-run tool if ADB is unavailable. Specifically for 'devices -l', it maps to 'native-run android --list' when falling back.
    async executeAdbWithFallback(
      adbArgs: string[],
      context: { deviceId?: string; platform?: 'android' | 'ios' } = {}
    ): Promise<FallbackResult> {
      const adbAvailable = await this.checkToolAvailability(RequiredTool.ADB);
      const nativeRunAvailable = await this.checkToolAvailability(RequiredTool.NATIVE_RUN);
    
      // Try ADB first if available
      if (adbAvailable) {
        try {
          const result = await processExecutor.execute('adb', adbArgs);
          return {
            success: true,
            usedFallback: false,
            originalTool: 'adb',
            data: result
          };
        } catch (error: any) {
          // ADB failed, try fallback
          if (nativeRunAvailable) {
            return await this.executeNativeRunFallback(adbArgs, context, error.message);
          }
          throw error;
        }
      }
    
      // Use native-run as fallback
      if (nativeRunAvailable) {
        return await this.executeNativeRunFallback(adbArgs, context, 'ADB not available');
      }
    
      return {
        success: false,
        usedFallback: false,
        originalTool: 'adb',
        error: 'Neither ADB nor native-run are available'
      };
    }
  • Metadata schema/definition for android_list_devices tool categorizing it as essential Android tool requiring ADB, safe for testing, with performance expectations.
    'android_list_devices': {
      name: 'android_list_devices',
      category: ToolCategory.ESSENTIAL,
      platform: 'android',
      requiredTools: [RequiredTool.ADB],
      description: 'List connected Android devices and emulators',
      safeForTesting: true,
      performance: { expectedDuration: 500, timeout: 10000 }
    },
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the tool's behavior of listing connected items and mentions fallback support, which adds some context. However, it lacks details on output format, error handling, or performance characteristics, leaving gaps in behavioral understanding for a tool with potential environment dependencies.

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, efficient sentence that front-loads the core purpose ('List connected Android devices and emulators') and adds a useful behavioral note ('supports ADB fallback to native-run') without any wasted words. Every part earns its place.

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

Completeness3/5

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

Given the tool's low complexity (0 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and a key behavioral trait, but for a tool that interacts with development environments, more context on output format or error cases would enhance completeness, though not strictly required.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the absence of inputs. The description adds no parameter information, which is appropriate here. A baseline of 4 is applied as it doesn't need to compensate for any parameter gaps.

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 ('connected Android devices and emulators'), making the purpose immediately understandable. It distinguishes from some siblings like 'android_list_emulators' by including both devices and emulators, but doesn't explicitly differentiate from 'flutter_list_devices' or 'native_run_list_devices' in terms of scope or method.

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

Usage Guidelines3/5

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

The description implies usage context by mentioning 'ADB fallback to native-run', suggesting it's for Android development environments. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'flutter_list_devices' or 'native_run_list_devices', leaving the choice ambiguous for the agent.

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/cristianoaredes/mcp-mobile-server'

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