Skip to main content
Glama

native_run_list_devices

List connected Android and iOS devices for mobile development testing and deployment using native-run commands.

Instructions

List connected devices using native-run (Android & iOS support)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
platformNoandroid

Implementation Reference

  • Handler function that validates input with Zod schema, checks if native-run is available, executes 'native-run [platform] --list --json', parses the JSON output or falls back to text line parsing, and returns a structured list of devices.
    handler: async (args: any) => { const parsed = NativeRunListDevicesSchema.parse(args); if (!(await isNativeRunAvailable())) { throw new Error('native-run is not installed. Install with: npm install -g native-run'); } const result = await processExecutor.execute('native-run', [ parsed.platform, '--list', '--json' ]); if (result.exitCode !== 0) { throw new Error(`Failed to list ${parsed.platform} devices: ${result.stderr}`); } let devices = []; try { const output = JSON.parse(result.stdout); devices = output.devices || []; } catch (parseError) { // If JSON parsing fails, try to parse text output devices = result.stdout .split('\n') .filter((line: string) => line.trim() && !line.includes('Available targets')) .map((line: string, index: number) => ({ id: `device_${index}`, name: line.trim(), platform: parsed.platform, available: true })); } return { success: true, data: { platform: parsed.platform, devices, totalCount: devices.length, tool: 'native-run' }, }; }
  • Zod validation schema for the tool input, specifying the 'platform' parameter as an enum of 'android' or 'ios' with default 'android'.
    const NativeRunListDevicesSchema = z.object({ platform: z.enum(['android', 'ios']).default('android'), });
  • Registers the 'native_run_list_devices' tool in the Map returned by createNativeRunTools(), including name, description, JSON input schema, and reference to the handler function.
    tools.set('native_run_list_devices', { name: 'native_run_list_devices', description: 'List connected devices using native-run (Android & iOS support)', inputSchema: { type: 'object', properties: { platform: { type: 'string', enum: ['android', 'ios'], default: 'android' } }, required: [] }, handler: async (args: any) => { const parsed = NativeRunListDevicesSchema.parse(args); if (!(await isNativeRunAvailable())) { throw new Error('native-run is not installed. Install with: npm install -g native-run'); } const result = await processExecutor.execute('native-run', [ parsed.platform, '--list', '--json' ]); if (result.exitCode !== 0) { throw new Error(`Failed to list ${parsed.platform} devices: ${result.stderr}`); } let devices = []; try { const output = JSON.parse(result.stdout); devices = output.devices || []; } catch (parseError) { // If JSON parsing fails, try to parse text output devices = result.stdout .split('\n') .filter((line: string) => line.trim() && !line.includes('Available targets')) .map((line: string, index: number) => ({ id: `device_${index}`, name: line.trim(), platform: parsed.platform, available: true })); } return { success: true, data: { platform: parsed.platform, devices, totalCount: devices.length, tool: 'native-run' }, }; } });
  • Helper function used by the handler to check if the native-run CLI is installed and available in the system PATH by attempting to run 'native-run --version'.
    async function isNativeRunAvailable(): Promise<boolean> { try { await processExecutor.execute('native-run', ['--version']); return true; } catch { return false; } }

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/cristianoaredes/mcp-mobile-server'

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