How mobile-next/mobile-mcp works
Project Type and Purpose
• This is an open‐source, platform‐agnostic CLI/server (Node.js) that implements the Model Context Protocol (MCP) for mobile automation.
• It exposes a standard MCP interface (via STDIO) so clients (IDEs or agent frameworks) can drive iOS/Android apps on simulators, emulators, or real devices using native accessibility snapshots or image‐based fallbacks.
File‐Structure Analysis
• Top‐level entries:
– server.json, package.json, tsconfig.json, build/config files
– src/ directory containing all TypeScript modules
– test/ directory with corresponding unit tests
• Key modules in src/:
– index.ts / mobilecli.ts – application entrypoints & CLI parsing
– server.ts – Core MCP server implementation (message routing, request/response lifecycle)
– android.ts, ios.ts, iphone‐simulator.ts – platform‐specific drivers/interfaces
– webdriver‐agent.ts – iOS WebDriverAgent bridge
– robot.ts – coordinate‐based tap simulation
– png.ts, image‐utils.ts – image decoding & screenshot analysis
– logger.ts – centralized logging utility
Architecture from README
– Clients (Agents, LLMs, IDEs) ↔ MCP Server ↔ Device drivers (Android, iOS, Simulator)
– Fallback flows: Accessibility Tree vs. Screenshot + Image Analysis
• Dependencies & protocols:
– STDIO (MCP messages)
– ADB (Android Platform Tools)
– xcrun / simctl / WebDriverAgent (iOS)
– Node.js v22+ runtime