flutter_launch_emulator
Launch a Flutter emulator by specifying its ID to test mobile applications during development.
Instructions
Launch a Flutter emulator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| emulatorId | Yes | Emulator ID to launch |
Implementation Reference
- src/tools/flutter.ts:428-459 (handler)Handler function that launches the specified Flutter emulator by executing the 'flutter emulators --launch [emulatorId]' command after validating the input.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, }, }; }
- src/tools/flutter.ts:48-50 (schema)Zod validation schema defining the input parameters for the flutter_launch_emulator tool (emulatorId: string).const FlutterEmulatorLaunchSchema = z.object({ emulatorId: z.string().min(1), });
- src/tools/flutter.ts:418-460 (registration)Registration of the flutter_launch_emulator tool in the createFlutterTools function, including name, description, inputSchema, and reference to the 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, }, }; } });
- src/tools/flutter.ts:421-426 (schema)JSON schema used for MCP tool input validation, mirroring the Zod schema.inputSchema: { type: 'object', properties: { emulatorId: { type: 'string', minLength: 1, description: 'Emulator ID to launch' } }, required: ['emulatorId']