Skip to main content
Glama

flutter_dev_session

Set up Flutter development environment, manage devices, and run applications with hot reload for efficient mobile app development.

Instructions

Complete Flutter dev setup: check env, list devices, select best device, run with hot reload

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdYesWorking directory (Flutter project root)
targetNoTarget dart file (e.g., lib/main.dart)
preferPhysicalNoPrefer physical device over emulator

Implementation Reference

  • Full tool definition and handler implementation for 'flutter_dev_session'. The handler orchestrates multiple steps: flutter doctor check, list and select device (prefer physical), run the app on selected device, or launch emulator and retry if no device available.
    tools.set('flutter_dev_session', { name: 'flutter_dev_session', description: 'Complete Flutter dev setup: check env, list devices, select best device, run with hot reload', inputSchema: { type: 'object', properties: { cwd: { type: 'string', description: 'Working directory (Flutter project root)' }, target: { type: 'string', description: 'Target dart file (e.g., lib/main.dart)' }, preferPhysical: { type: 'boolean', description: 'Prefer physical device over emulator', default: true } }, required: ['cwd'] }, handler: async (args: any) => { const steps = []; try { // Step 1: Run flutter doctor const doctorTool = flutterTools.get('flutter_doctor'); const doctorResult = await doctorTool.handler({}); steps.push({ step: 'doctor', ...doctorResult }); // Step 2: List available devices const listTool = flutterTools.get('flutter_list_devices'); const devicesResult = await listTool.handler({}); steps.push({ step: 'list_devices', ...devicesResult }); // Step 3: Select best device let selectedDevice = null; if (devicesResult.success && devicesResult.data?.devices?.length > 0) { const devices = devicesResult.data.devices; // Prioritize based on preference if (args.preferPhysical) { selectedDevice = devices.find((d: any) => !d.emulator) || devices[0]; } else { selectedDevice = devices[0]; } } // Step 4: Run flutter app if (selectedDevice) { const runTool = flutterTools.get('flutter_run'); const runResult = await runTool.handler({ cwd: args.cwd, deviceId: selectedDevice.id, target: args.target }); steps.push({ step: 'run', ...runResult }); return { success: true, data: { selectedDevice, sessionId: runResult.data?.sessionId, steps, message: `Flutter dev session started on ${selectedDevice.name}` } }; } else { // No device available - try to start emulator const emulatorsResult = await flutterTools.get('flutter_list_emulators').handler({}); if (emulatorsResult.success && emulatorsResult.data?.emulators?.length > 0) { const emulator = emulatorsResult.data.emulators[0]; await flutterTools.get('flutter_launch_emulator').handler({ emulatorId: emulator.id }); // Wait and retry await new Promise(resolve => setTimeout(resolve, 5000)); return tools.get('flutter_dev_session').handler(args); } return { success: false, error: 'No devices available and no emulators to launch', steps }; } } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error), steps }; } } });
  • Input schema defining parameters for the tool: cwd (required), target, preferPhysical (default true).
    inputSchema: { type: 'object', properties: { cwd: { type: 'string', description: 'Working directory (Flutter project root)' }, target: { type: 'string', description: 'Target dart file (e.g., lib/main.dart)' }, preferPhysical: { type: 'boolean', description: 'Prefer physical device over emulator', default: true } }, required: ['cwd'] },
  • Tool metadata registration in the central TOOL_REGISTRY, categorizing it as essential Flutter tool with performance estimates and requirements.
    'flutter_dev_session': { name: 'flutter_dev_session', category: ToolCategory.ESSENTIAL, platform: 'flutter', requiredTools: [RequiredTool.FLUTTER], description: 'Complete Flutter dev setup: check env, list devices, select best device, run with hot reload', safeForTesting: false, performance: { expectedDuration: 90000, timeout: 300000 }

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