Skip to main content
Glama

android_start_emulator

Start an Android emulator for development and testing by specifying the AVD name and optional configuration settings like GPU mode and console port.

Instructions

Start an Android emulator

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
avdNameYesAVD name to start
optionsNo

Implementation Reference

  • The handler function for android_start_emulator tool. Validates input using Zod schema, checks if emulator is already running, spawns the emulator process with options, tracks the PID in runningEmulators map, and sets up exit handler.
    handler: async (args: any) => {
      const validation = AndroidEmulatorStartSchema.safeParse(args);
      if (!validation.success) {
        throw new Error(`Invalid request: ${validation.error.message}`);
      }
    
      const { avdName, options = {} } = validation.data;
    
      // Check if emulator is already running
      if (runningEmulators.has(avdName)) {
        return {
          success: true,
          data: {
            avdName,
            status: 'already_running',
            pid: runningEmulators.get(avdName),
            message: 'Emulator is already running',
          },
        };
      }
    
      const emulator_args = ['-avd', avdName];
      
      if (options.noWindow) {
        emulator_args.push('-no-window');
      }
      
      if (options.port) {
        emulator_args.push('-port', options.port.toString());
      }
      
      if (options.gpu) {
        emulator_args.push('-gpu', options.gpu);
      }
    
      // Start emulator in background
      const emulatorProcess = spawn('emulator', emulator_args, {
        detached: true,
        stdio: 'ignore',
      });
    
      // Track the process
      runningEmulators.set(avdName, emulatorProcess.pid!);
    
      // Handle process exit
      emulatorProcess.on('exit', () => {
        runningEmulators.delete(avdName);
      });
    
      // Unref to allow the parent process to exit
      emulatorProcess.unref();
    
      return {
        success: true,
        data: {
          avdName,
          pid: emulatorProcess.pid,
          status: 'started',
          options,
        },
      };
    }
  • Zod validation schema used in the handler for input parameters: avdName (required string), options (optional object with noWindow boolean, port number 5554-5682, gpu enum).
    const AndroidEmulatorStartSchema = z.object({
      avdName: z.string().min(1),
      options: z.object({
        noWindow: z.boolean().optional(),
        port: z.number().min(5554).max(5682).optional(),
        gpu: z.enum(['auto', 'host', 'swiftshader_indirect', 'angle_indirect', 'guest']).optional(),
      }).optional(),
    });
  • Registration of the android_start_emulator tool within the createAndroidTools function. Defines name, description, inputSchema (JSON schema), and references the handler function.
    tools.set('android_start_emulator', {
      name: 'android_start_emulator',
      description: 'Start an Android emulator',
      inputSchema: {
        type: 'object',
        properties: {
          avdName: { type: 'string', minLength: 1, description: 'AVD name to start' },
          options: {
            type: 'object',
            properties: {
              noWindow: { type: 'boolean', description: 'Run without UI window' },
              port: { type: 'number', minimum: 5554, maximum: 5682, description: 'Console port number' },
              gpu: { 
                type: 'string', 
                enum: ['auto', 'host', 'swiftshader_indirect', 'angle_indirect', 'guest'],
                description: 'GPU acceleration mode'
              }
            }
          }
        },
        required: ['avdName']
      },
      handler: async (args: any) => {
        const validation = AndroidEmulatorStartSchema.safeParse(args);
        if (!validation.success) {
          throw new Error(`Invalid request: ${validation.error.message}`);
        }
    
        const { avdName, options = {} } = validation.data;
    
        // Check if emulator is already running
        if (runningEmulators.has(avdName)) {
          return {
            success: true,
            data: {
              avdName,
              status: 'already_running',
              pid: runningEmulators.get(avdName),
              message: 'Emulator is already running',
            },
          };
        }
    
        const emulator_args = ['-avd', avdName];
        
        if (options.noWindow) {
          emulator_args.push('-no-window');
        }
        
        if (options.port) {
          emulator_args.push('-port', options.port.toString());
        }
        
        if (options.gpu) {
          emulator_args.push('-gpu', options.gpu);
        }
    
        // Start emulator in background
        const emulatorProcess = spawn('emulator', emulator_args, {
          detached: true,
          stdio: 'ignore',
        });
    
        // Track the process
        runningEmulators.set(avdName, emulatorProcess.pid!);
    
        // Handle process exit
        emulatorProcess.on('exit', () => {
          runningEmulators.delete(avdName);
        });
    
        // Unref to allow the parent process to exit
        emulatorProcess.unref();
    
        return {
          success: true,
          data: {
            avdName,
            pid: emulatorProcess.pid,
            status: 'started',
            options,
          },
        };
      }
    });
  • Metadata registration in tool registry: categorizes as ESSENTIAL android tool requiring EMULATOR, with performance expectations.
    'android_start_emulator': {
      name: 'android_start_emulator',
      category: ToolCategory.ESSENTIAL,
      platform: 'android',
      requiredTools: [RequiredTool.EMULATOR],
      description: 'Start Android emulator',
      safeForTesting: false,
      performance: { expectedDuration: 60000, timeout: 180000 }
    },
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It only states the action ('Start') without mentioning potential side effects (e.g., resource consumption, startup time), success/failure conditions, or interactions with other tools like 'android_stop_emulator'. This leaves significant gaps in understanding the tool's behavior.

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, direct sentence with zero wasted words, making it highly concise and front-loaded. It efficiently communicates the core action without unnecessary elaboration, earning a top score for brevity and clarity.

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

Completeness2/5

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

Given the complexity (starting an emulator with configurable options), lack of annotations, and no output schema, the description is incomplete. It omits critical context such as expected outcomes (e.g., emulator boot success), error handling, or dependencies on other tools like 'android_create_avd'. This leaves the agent with insufficient information for reliable use.

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 50%, with the 'avdName' parameter well-documented but the 'options' object lacking descriptions for its nested properties. The description adds no parameter semantics beyond the schema, failing to compensate for the coverage gap. However, with two parameters and some schema documentation, it meets the baseline of 3.

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 'Start an Android emulator' clearly states the verb ('Start') and resource ('Android emulator'), making the purpose immediately understandable. However, it does not distinguish this tool from its sibling 'flutter_launch_emulator', which likely serves a similar function in a different context, preventing a score of 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'android_list_emulators' (for checking status) or 'flutter_launch_emulator' (for Flutter-specific workflows). It also lacks prerequisites, such as requiring an existing AVD or proper SDK setup, leaving usage context unclear.

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