Skip to main content
Glama

flutter_launch_emulator

Launch a Flutter emulator for testing mobile applications by specifying the emulator ID, enabling developers to run and debug their Flutter projects on virtual devices.

Instructions

Launch a Flutter emulator

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emulatorIdYesEmulator ID to launch

Implementation Reference

  • Handler function that launches the specified Flutter emulator. Validates input using Zod schema, checks emulator ID format, executes 'flutter emulators --launch [emulatorId]' with 3-minute timeout, handles errors, and returns structured success response.
    handler: async (args: any) => { const validation = FlutterEmulatorLaunchSchema.safeParse(args); if (!validation.success) { throw new Error(`Invalid request: ${validation.error.message}`); } const { emulatorId } = validation.data; // Validate emulator ID format (alphanumeric, underscores, dots, dashes) if (!/^[a-zA-Z0-9._-]+$/.test(emulatorId)) { throw new Error(`Invalid emulator ID format. Emulator ID can only contain alphanumeric characters, dots, underscores, and dashes: ${emulatorId}`); } const result = await processExecutor.execute( 'flutter', ['emulators', '--launch', emulatorId], { timeout: 180000 } // 3 minutes timeout for emulator launch ); if (result.exitCode !== 0) { throw new Error(`Failed to launch emulator: ${result.stderr || result.stdout}`); } return { success: true, data: { emulatorId, status: 'launched', output: result.stdout, }, }; }
  • Zod schema for validating input parameters of flutter_launch_emulator tool (emulatorId: non-empty string). Referenced in the handler for runtime validation.
    * Zod validation schema for flutter_launch_emulator tool. * Validates emulator ID parameter. * * @type {z.ZodObject} */ const FlutterEmulatorLaunchSchema = z.object({ emulatorId: z.string().min(1), });
  • Registers the flutter_launch_emulator tool in the tools Map within createFlutterTools function, defining name, description, JSON inputSchema, and handler.
    tools.set('flutter_launch_emulator', { name: 'flutter_launch_emulator', description: 'Launch a Flutter emulator', inputSchema: { type: 'object', properties: { emulatorId: { type: 'string', minLength: 1, description: 'Emulator ID to launch' } }, required: ['emulatorId'] }, handler: async (args: any) => { const validation = FlutterEmulatorLaunchSchema.safeParse(args); if (!validation.success) { throw new Error(`Invalid request: ${validation.error.message}`); } const { emulatorId } = validation.data; // Validate emulator ID format (alphanumeric, underscores, dots, dashes) if (!/^[a-zA-Z0-9._-]+$/.test(emulatorId)) { throw new Error(`Invalid emulator ID format. Emulator ID can only contain alphanumeric characters, dots, underscores, and dashes: ${emulatorId}`); } const result = await processExecutor.execute( 'flutter', ['emulators', '--launch', emulatorId], { timeout: 180000 } // 3 minutes timeout for emulator launch ); if (result.exitCode !== 0) { throw new Error(`Failed to launch emulator: ${result.stderr || result.stdout}`); } return { success: true, data: { emulatorId, status: 'launched', output: result.stdout, }, }; } });

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