Skip to main content
Glama

flutter_dev_session

Set up Flutter development sessions by checking environment, listing devices, selecting optimal hardware, and running projects 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

  • Core handler implementing the complete Flutter development session workflow: flutter doctor check, device detection and selection (preferring physical devices), app launch with hot reload support, and automatic emulator launch fallback with recursive retry.
    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), optional target file and preferPhysical flag.
    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']
    },
  • Registration of the flutter_dev_session super-tool in the tools Map within createSuperTools function.
    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
          };
        }
      }
    });
  • Metadata entry in TOOL_REGISTRY providing categorization, platform info, requirements, and performance expectations for health checks and tool management.
    '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 }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions actions like 'run with hot reload' but lacks details on permissions needed, whether it modifies files, error handling, or output format. For a multi-step setup tool with zero annotation coverage, this is a significant gap in behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the main purpose ('Complete Flutter dev setup') followed by key actions. Every phrase earns its place with no wasted words, making it easy to scan and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (multi-step setup) and lack of annotations or output schema, the description is minimally adequate. It outlines the sequence of actions but misses details like what 'best device' means, how errors are handled, or what the output contains. It meets basic needs but leaves gaps for an agent to operate effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters. The description doesn't add any parameter-specific information beyond what's in the schema, such as explaining how 'preferPhysical' affects device selection. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('check env, list devices, select best device, run with hot reload') and identifies the resource as Flutter development setup. It distinguishes from siblings like 'flutter_run' by emphasizing comprehensive setup rather than just execution, though it doesn't explicitly name alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context ('Complete Flutter dev setup') but doesn't explicitly state when to use this tool versus alternatives like 'flutter_run' or 'flutter_setup_environment'. No exclusions or prerequisites are mentioned, leaving the agent to infer based on the described functionality.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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