Skip to main content
Glama

multi_device

Run the same action on multiple devices and get combined results. Ideal for testing across iOS and Android with a single command.

Instructions

Execute la meme action sur plusieurs devices et retourne les resultats combines. Utile pour tester sur iOS + Android en une seule commande.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idsYesListe des device IDs a cibler
actionYesAction a executer sur chaque device
bundle_idNoBundle ID / package name (requis pour launch_app/kill_app)

Implementation Reference

  • The registerMultiDevice function registers the 'multi_device' tool on the MCP server. The handler iterates over provided device_ids, validates each device, and executes the requested action (screenshot, get_ui_tree, launch_app, kill_app) sequentially across iOS and Android devices. It restores the original ADB serial in a finally block.
    export function registerMultiDevice(server: McpServer): void {
      server.tool(
        "multi_device",
        "Execute la meme action sur plusieurs devices et retourne les resultats combines. Utile pour tester sur iOS + Android en une seule commande.",
        {
          device_ids: z.array(z.string()).min(1).describe("Liste des device IDs a cibler"),
          action: z.enum(["screenshot", "get_ui_tree", "launch_app", "kill_app"]).describe("Action a executer sur chaque device"),
          bundle_id: z.string().optional().describe("Bundle ID / package name (requis pour launch_app/kill_app)"),
        },
        async ({ device_ids, action, bundle_id }) => {
          // Validate bundle_id for app actions
          if ((action === "launch_app" || action === "kill_app") && !bundle_id) {
            return { content: [{ type: "text", text: `Le parametre bundle_id est requis pour ${action}.` }], isError: true };
          }
    
          // Save current state to restore later
          const savedSerial = getCurrentAdbSerial();
    
          // Resolve all devices
          const devices: Array<{ device: DeviceInfo; error?: string }> = [];
          for (const id of device_ids) {
            const dev = await getDeviceById(id);
            if (!dev) {
              devices.push({ device: { id, name: id, platform: "ios", type: "simulator", state: "shutdown" }, error: `Device "${id}" non trouve` });
            } else if (dev.state !== "booted") {
              devices.push({ device: dev, error: `Device "${dev.name}" n'est pas demarre` });
            } else {
              devices.push({ device: dev });
            }
          }
    
          const content: Array<{ type: "text"; text: string } | { type: "image"; data: string; mimeType: string }> = [];
          let hasError = false;
    
          try {
            // Execute sequentially (ADB serial and WDA are singletons)
            for (let i = 0; i < devices.length; i++) {
              const { device: dev, error } = devices[i];
              const platform = dev.platform === "ios" ? "🍎" : "🤖";
              const header = `[${i + 1}/${devices.length}] ${platform} ${dev.name}`;
    
              if (error) {
                content.push({ type: "text", text: `${header}\n  ERREUR : ${error}\n` });
                hasError = true;
                continue;
              }
    
              try {
                if (dev.platform === "android") setAdbSerial(dev.id);
    
                switch (action) {
                  case "screenshot": {
                    const buffer = dev.platform === "ios"
                      ? await iosScreenshot(dev.id)
                      : await androidScreenshot();
                    content.push({ type: "text", text: `${header} — screenshot :` });
                    content.push({ type: "image", data: buffer.toString("base64"), mimeType: "image/png" });
                    break;
                  }
    
                  case "get_ui_tree": {
                    let elements;
                    if (dev.platform === "ios") {
                      const wda = await ensureWdaRunning(dev);
                      if (!wda.ready) throw new Error(wda.message ?? "WDA indisponible");
                      elements = await iosGetUiTree();
                    } else {
                      elements = await androidGetUiTree();
                    }
                    const lines = elements.map((el, idx) => {
                      const text = el.label || el.name || "";
                      return `  [${idx}] ${el.type} "${text}" (${el.x},${el.y} ${el.width}x${el.height})`;
                    });
                    content.push({ type: "text", text: `${header} — ${elements.length} elements :\n${lines.join("\n")}\n` });
                    break;
                  }
    
                  case "launch_app": {
                    if (dev.platform === "ios") await iosLaunchApp(dev.id, bundle_id!);
                    else await androidLaunchApp(bundle_id!);
                    content.push({ type: "text", text: `${header} — ${bundle_id} lance\n` });
                    break;
                  }
    
                  case "kill_app": {
                    if (dev.platform === "ios") await iosKillApp(dev.id, bundle_id!);
                    else await androidKillApp(bundle_id!);
                    content.push({ type: "text", text: `${header} — ${bundle_id} ferme\n` });
                    break;
                  }
                }
              } catch (err) {
                const msg = err instanceof Error ? err.message : String(err);
                content.push({ type: "text", text: `${header}\n  ERREUR : ${msg}\n` });
                hasError = true;
              }
            }
          } finally {
            // Always restore original ADB serial, even on unexpected errors
            setAdbSerial(savedSerial);
          }
    
          return { content, isError: hasError };
        }
      );
    }
  • Input schema for multi_device tool: device_ids (array of strings, min 1), action (enum: screenshot/get_ui_tree/launch_app/kill_app), bundle_id (optional string, required for launch_app/kill_app).
    {
      device_ids: z.array(z.string()).min(1).describe("Liste des device IDs a cibler"),
      action: z.enum(["screenshot", "get_ui_tree", "launch_app", "kill_app"]).describe("Action a executer sur chaque device"),
      bundle_id: z.string().optional().describe("Bundle ID / package name (requis pour launch_app/kill_app)"),
    },
  • src/index.ts:25-70 (registration)
    Import of registerMultiDevice from the multi-device module, and registration call at line 70.
    import { registerMultiDevice } from "./tools/multi-device.js";
    
    const server = new McpServer({
      name: "phantom",
      version: "2.3.0",
    });
    
    // Device management
    registerListDevices(server);
    registerSetDevice(server);
    registerPrepareDevice(server);
    
    // Observation
    registerScreenshot(server);
    registerGetUiTree(server);
    registerWaitForElement(server);
    registerScrollUntilVisible(server);
    
    // Assertions
    registerAssertVisible(server);
    registerAssertNotVisible(server);
    
    // Interaction
    registerTap(server);
    registerLongPress(server);
    registerTypeText(server);
    registerSwipe(server);
    registerDismissKeyboard(server);
    
    // Navigation
    registerDeepLink(server);
    
    // Device actions
    registerShake(server);
    registerRotate(server);
    registerVideoRecord(server);
    
    // App lifecycle
    registerLaunchApp(server);
    registerKillApp(server);
    
    // Tier 3 — Analysis & Automation
    registerAccessibilityAudit(server);
    registerTestReport(server);
    registerVisualDiff(server);
    registerMultiDevice(server);
  • getDeviceById helper used by multi_device to resolve each device ID from the available devices list.
    export async function getDeviceById(id: string): Promise<DeviceInfo | null> {
      const all = await getAllDevices();
      return all.find((d) => d.id === id) ?? null;
    }
  • DeviceInfo type definition used in the multi_device tool for device metadata.
    export interface DeviceInfo {
      id: string;
      name: string;
      platform: "ios" | "android";
      type: "simulator" | "emulator" | "device";
      state: "booted" | "shutdown";
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It only states the tool runs actions on multiple devices and returns combined results, but fails to disclose behavioral traits like failure handling, concurrency, destructive potential, or rate limits. This is insufficient for a multi-device orchestration tool.

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?

Two sentences, no redundancy, front-loaded with the core action. Every word serves a purpose, making it efficient for an AI agent to parse.

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?

Despite moderate complexity (multi-device execution), the description omits details like error handling, result format, synchronization semantics, and potential side effects. With no output schema or annotations, this leaves significant gaps for correct invocation and interpretation.

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 coverage is 100%, with all parameters documented. The description adds minimal value by mentioning combined results, but does not elaborate on the return format or constraints beyond schema. Baseline 3 is appropriate as schema already covers parameter meaning.

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

Purpose5/5

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

The description clearly states the tool's function: executing the same action on multiple devices and returning combined results. It explicitly mentions usefulness for testing on iOS + Android in one command, distinguishing it from single-device sibling tools like launch_app or screenshot.

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

Usage Guidelines4/5

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

The description indicates when to use this tool ('for testing on iOS + Android in one command'), implying batch testing scenarios. It does not explicitly exclude alternatives or provide when-not-to-use guidance, but the context is clear enough for an AI agent to infer appropriate usage.

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/nthImpulse/phantom-mcp'

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