adb_stop_app
Stop a running Android application on a device by specifying its package name. This tool helps manage app processes and free device resources through the ADB MCP Server.
Instructions
Stop an app on the device
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| packageName | Yes | Package name of the app to stop | |
| deviceId | No | Device ID (optional) |
Implementation Reference
- src/tools/app.ts:125-159 (handler)The main handler function that executes the ADB command to force-stop the specified app package.
async stopApp(packageName: string, deviceId?: string) { try { const connected = await this.adbClient.isDeviceConnected(deviceId); if (!connected) { return { success: false, error: 'Device not connected', message: 'Cannot stop app - device is not connected' }; } const command = `shell am force-stop ${packageName}`; const result = await this.adbClient.executeCommand(command, deviceId); if (!result.success) { return { success: false, error: result.error, message: 'Failed to stop app' }; } return { success: true, data: { packageName, deviceId: deviceId || this.adbClient.getDefaultDevice() }, message: `App ${packageName} stopped successfully` }; } catch (error: any) { return { success: false, error: error.message, message: 'Failed to stop app' }; } } - src/index.ts:259-276 (schema)Input schema definition for the adb_stop_app tool, specifying packageName as required and deviceId as optional.
{ name: 'adb_stop_app', description: 'Stop an app on the device', inputSchema: { type: 'object', properties: { packageName: { type: 'string', description: 'Package name of the app to stop', }, deviceId: { type: 'string', description: 'Device ID (optional)', }, }, required: ['packageName'], }, }, - src/index.ts:459-460 (registration)Registration of the tool handler in the switch statement, dispatching calls to AppTools.stopApp method.
case 'adb_stop_app': return await this.handleToolCall(this.appTools.stopApp(args?.packageName as string, args?.deviceId as string));