Skip to main content
Glama

list_devices

Discover connected Android devices and emulators to enable debugging, automation, and control through the Android MCP server.

Instructions

List connected Android devices and emulators

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Tool registration and handler for "list_devices" in index.ts.
    server.tool("list_devices", "List connected Android devices and emulators", {}, async () => {
      const devices = await adb.getDevices();
      if (devices.length === 0) {
        return {
          content: [
            {
              type: "text",
              text: "No devices connected. Use list_avds to see available emulators, then start_emulator to launch one.",
            },
          ],
        };
      }
      return {
        content: [
          {
            type: "text",
            text: devices
              .map((d) => `${d.id} [${d.state}]${d.model ? ` model:${d.model}` : ""}`)
              .join("\n"),
          },
        ],
      };
    });
  • The helper method getDevices that implements the logic of listing connected Android devices by calling `adb devices -l`.
    async getDevices(): Promise<Array<{ id: string; state: string; model?: string }>> {
      const output = await this.exec(["devices", "-l"]);
      const lines = output.split("\n").filter((l) => l.trim() && !l.startsWith("List of"));
      return lines.map((line) => {
        const parts = line.trim().split(/\s+/);
        const id = parts[0];
        const state = parts[1];
        const modelMatch = line.match(/model:(\S+)/);
        return { id, state, model: modelMatch?.[1] };
      }).filter((d) => d.id && d.state);
    }

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

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