MCPcopy
hub / github.com/mobile-next/mobile-mcp / getConnectedDevicesWithDetails

Method getConnectedDevicesWithDetails

src/android.ts:589–610  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

587 }
588
589 public getConnectedDevicesWithDetails(): Array<AndroidDevice & { version: string, name: string }> {
590 try {
591 const names = execFileSync(getAdbPath(), ["devices"])
592 .toString()
593 .split("\n")
594 .map(line => line.trim())
595 .filter(line => line !== "")
596 .filter(line => !line.startsWith("List of devices attached"))
597 .filter(line => line.split("\t")[1]?.trim() === "device") // Only include devices that are online and ready
598 .map(line => line.split("\t")[0]);
599
600 return names.map(deviceId => ({
601 deviceId,
602 deviceType: this.getDeviceType(deviceId),
603 version: this.getDeviceVersion(deviceId),
604 name: this.getDeviceName(deviceId),
605 }));
606 } catch (error) {
607 console.error("Could not execute adb command, maybe ANDROID_HOME is not set?");
608 return [];
609 }
610 }
611}

Callers 1

createMcpServerFunction · 0.95

Calls 4

getDeviceTypeMethod · 0.95
getDeviceVersionMethod · 0.95
getDeviceNameMethod · 0.95
getAdbPathFunction · 0.85

Tested by

no test coverage detected