Skip to main content
Glama

native_run_list_devices

List connected Android and iOS devices for mobile development, enabling device management and testing workflows.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
platformNoandroid

Implementation Reference

  • The core handler function for the 'native_run_list_devices' tool. Validates input using Zod schema, checks if native-run is available, executes the 'native-run [platform] --list --json' command, parses the JSON output (with fallback to text parsing), and returns a structured response with device list.
    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 input parameters of native_run_list_devices tool (platform: 'android' | 'ios', default 'android'). Used in the handler for input validation.
    const NativeRunListDevicesSchema = z.object({ platform: z.enum(['android', 'ios']).default('android'), });
  • Primary registration of the native_run_list_devices tool within createNativeRunTools(), defining name, description, JSON inputSchema, and inline 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' }, }; } });
  • Secondary registration in createAndroidTools() where native-run tools (including native_run_list_devices) are instantiated via createNativeRunTools() and merged into the comprehensive Android tools Map.
    const nativeRunTools = createNativeRunTools(); // Merge all tools for (const [name, tool] of gradleTools.entries()) { tools.set(name, tool); } for (const [name, tool] of lintTools.entries()) { tools.set(name, tool); } for (const [name, tool] of mediaTools.entries()) { tools.set(name, tool); } for (const [name, tool] of nativeRunTools.entries()) { tools.set(name, tool); }
  • Helper function to check if native-run CLI is installed and available in system PATH. Used by the handler to validate prerequisites before execution.
    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