Skip to main content
Glama

android_stop_emulator

Stop a running Android emulator by specifying its AVD name to free system resources and manage development environments.

Instructions

Stop a running Android emulator

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
avdNameYesAVD name to stop

Implementation Reference

  • The async handler function validates the input using AndroidEmulatorStopSchema, retrieves the PID of the running emulator from the global runningEmulators map, kills the process using process.kill(pid, 'SIGTERM'), removes it from tracking, and returns success status.
    handler: async (args: any) => { const validation = AndroidEmulatorStopSchema.safeParse(args); if (!validation.success) { throw new Error(`Invalid request: ${validation.error.message}`); } const { avdName } = validation.data; const pid = runningEmulators.get(avdName); if (!pid) { throw new Error(`Emulator is not running or not tracked by this server. No running emulator found for AVD: ${avdName}`); } try { // Kill the process process.kill(pid, 'SIGTERM'); // Remove from tracking runningEmulators.delete(avdName); return { success: true, data: { avdName, pid, status: 'stopped', }, }; } catch (killError) { // Process might already be dead runningEmulators.delete(avdName); return { success: true, data: { avdName, pid, status: 'already_stopped', message: 'Process was already terminated', }, }; } }
  • Zod validation schema for the android_stop_emulator tool input, requiring a non-empty 'avdName' string.
    const AndroidEmulatorStopSchema = z.object({ avdName: z.string().min(1), });
  • Registration of the 'android_stop_emulator' tool in the tools Map within createAndroidTools function, including name, description, inputSchema (JSON schema), and reference to the handler function.
    tools.set('android_stop_emulator', { name: 'android_stop_emulator', description: 'Stop a running Android emulator', inputSchema: { type: 'object', properties: { avdName: { type: 'string', minLength: 1, description: 'AVD name to stop' } }, required: ['avdName'] }, handler: async (args: any) => { const validation = AndroidEmulatorStopSchema.safeParse(args); if (!validation.success) { throw new Error(`Invalid request: ${validation.error.message}`); } const { avdName } = validation.data; const pid = runningEmulators.get(avdName); if (!pid) { throw new Error(`Emulator is not running or not tracked by this server. No running emulator found for AVD: ${avdName}`); } try { // Kill the process process.kill(pid, 'SIGTERM'); // Remove from tracking runningEmulators.delete(avdName); return { success: true, data: { avdName, pid, status: 'stopped', }, }; } catch (killError) { // Process might already be dead runningEmulators.delete(avdName); return { success: true, data: { avdName, pid, status: 'already_stopped', message: 'Process was already terminated', }, }; } } });

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