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
| Name | Required | Description | Default |
|---|---|---|---|
| avdName | Yes | AVD name to stop |
Implementation Reference
- src/tools/android.ts:635-677 (handler)Handler function that validates input, retrieves the emulator PID from tracking map, sends SIGTERM signal to stop it, removes from tracking, handles case where process already terminated.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', }, }; } }
- src/tools/android.ts:130-137 (schema)Zod validation schema for the android_stop_emulator tool input, requiring 'avdName' as a non-empty string.* Zod validation schema for android_stop_emulator tool. * * @type {z.ZodObject} * @property {string} avdName - AVD name to stop */ const AndroidEmulatorStopSchema = z.object({ avdName: z.string().min(1), });
- src/tools/android.ts:625-678 (registration)Registration of the 'android_stop_emulator' tool in the tools Map returned by createAndroidTools function, including name, description, inputSchema, and handler reference.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', }, }; } } });
- src/utils/tool-categories.ts:152-159 (helper)Metadata entry in TOOL_REGISTRY defining category, platform, requirements, and performance expectations for the tool.'android_stop_emulator': { name: 'android_stop_emulator', category: ToolCategory.ESSENTIAL, platform: 'android', requiredTools: [RequiredTool.ADB], description: 'Stop running Android emulator', safeForTesting: false, performance: { expectedDuration: 5000, timeout: 30000 }
- scripts/validate-tools.ts:168-168 (helper)Mapping in validation script indicating the tool requires 'adb' for operation.'android_stop_emulator': 'adb',