Skip to main content
Glama

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
NameRequiredDescriptionDefault
emulatorIdYesEmulator ID to launch

Implementation Reference

  • 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, }, }; }
  • Zod validation schema defining the input parameters for the flutter_launch_emulator tool (emulatorId: string).
    const FlutterEmulatorLaunchSchema = z.object({ emulatorId: z.string().min(1), });
  • 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, }, }; } });
  • 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']

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