Skip to main content
Glama

list_devices

Retrieve a list of all connected Android devices with their current status and model details for device management and automation.

Instructions

List all connected Android devices with their status and model information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core implementation of device listing, which executes 'adb devices -l'.
    /**
     * List all connected devices.
     */
    async listDevices(): Promise<DeviceInfo[]> {
      const result = await adbExec(['devices', '-l']);
      const lines = result.stdout.split('\n').filter(l => l.trim() && !l.startsWith('List'));
    
      const devices: DeviceInfo[] = [];
      for (const line of lines) {
        const parts = line.trim().split(/\s+/);
        if (parts.length >= 2) {
          const id = parts[0];
          const status = parts[1];
    
          // Parse device properties from -l output
          const props: Record<string, string> = {};
          for (const part of parts.slice(2)) {
            const [key, value] = part.split(':');
            if (key && value) props[key] = value;
          }
    
          devices.push({
            id,
            status,
            model: props['model'],
          });
        }
      }
    
      return devices;
    }
  • Registration of the 'list_devices' tool in the MCP server.
    export function registerDeviceTools(server: McpServer): void {
      server.registerTool(
        'list_devices',
        {
          description: 'List all connected Android devices with their status and model information',
          inputSchema: {},
        },
        async () => {
          return await metrics.measure('list_devices', 'all', async () => {
            const devices = await deviceManager.listDevices();
            return {
              content: [{
                type: 'text' as const,
                text: JSON.stringify({ success: true, devices }, null, 2),
              }],
            };
          });
        }
      );

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/divineDev-dotcom/android_mcp'

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