mobile_open_url
Open URLs directly in mobile device browsers to test web content, verify links, or automate navigation tasks on iOS and Android devices.
Instructions
Open a URL in browser on device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device | Yes | The device identifier to use. Use mobile_list_available_devices to find which devices are available to you. | |
| url | Yes | The URL to open |
Implementation Reference
- src/server.ts:441-454 (registration)Full registration of the MCP tool 'mobile_open_url', including title, description, input schema (device and url), and the handler function. The handler retrieves the appropriate Robot instance based on the device and calls its openUrl method.tool( "mobile_open_url", "Open URL", "Open a URL in browser on device", { device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."), url: z.string().describe("The URL to open"), }, async ({ device, url }) => { const robot = getRobotFromDevice(device); await robot.openUrl(url); return `Opened URL: ${url}`; } );
- src/server.ts:449-453 (handler)The executing handler logic for the tool: fetches the Robot for the given device and invokes robot.openUrl(url).async ({ device, url }) => { const robot = getRobotFromDevice(device); await robot.openUrl(url); return `Opened URL: ${url}`; }
- src/server.ts:446-448 (schema)Input schema using Zod: requires 'device' (string) and 'url' (string) parameters.device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."), url: z.string().describe("The URL to open"), },
- src/server.ts:142-179 (helper)Helper function getRobotFromDevice that selects the correct Robot subclass (IosRobot, AndroidRobot, or MobileDevice) based on the device ID, used by the tool handler.const getRobotFromDevice = (deviceId: string): Robot => { // from now on, we must have mobilecli working ensureMobilecliAvailable(); // Check if it's an iOS device const iosManager = new IosManager(); const iosDevices = iosManager.listDevices(); const iosDevice = iosDevices.find(d => d.deviceId === deviceId); if (iosDevice) { return new IosRobot(deviceId); } // Check if it's an Android device const androidManager = new AndroidDeviceManager(); const androidDevices = androidManager.getConnectedDevices(); const androidDevice = androidDevices.find(d => d.deviceId === deviceId); if (androidDevice) { return new AndroidRobot(deviceId); } // Check if it's a simulator (will later replace all other device types as well) const response = mobilecli.getDevices({ platform: "ios", type: "simulator", includeOffline: false, }); if (response.status === "ok" && response.data && response.data.devices) { for (const device of response.data.devices) { if (device.id === deviceId) { return new MobileDevice(deviceId); } } } throw new ActionableError(`Device "${deviceId}" not found. Use the mobile_list_available_devices tool to see available devices.`); };