Skip to main content
Glama

close_app

Force-stop an Android application by its package name to manage device resources and resolve unresponsive apps.

Instructions

Force-stop an Android application by its package name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
package_nameYesAndroid package name to close
device_idNoDevice serial number

Implementation Reference

  • The core implementation of the close_app logic using adb shell am force-stop.
    export async function closeApp(packageName: string, deviceId?: string): Promise<string> {
      const resolved = await deviceManager.resolveDeviceId(deviceId);
      validatePackageName(packageName);
    
      await adbShell(['am', 'force-stop', packageName], resolved);
    
      deviceManager.touchSession(resolved);
      log.info('App closed', { packageName, deviceId: resolved });
      return packageName;
    }
  • MCP tool registration and handler wrapper for 'close_app'.
    server.registerTool(
      'close_app',
      {
        description: 'Force-stop an Android application by its package name.',
        inputSchema: {
          package_name: z.string().describe('Android package name to close'),
          device_id: z.string().optional().describe('Device serial number'),
        },
      },
      async ({ package_name, device_id }) => {
        return await metrics.measure('close_app', device_id || 'default', async () => {
          const resolved = await deviceManager.resolveDeviceId(device_id);
          const execCtx = executionEngine.preExecutionCheck('close_app', { package_name }, resolved);
    
          if (!execCtx.allowed) {
            return {
              content: [{
                type: 'text' as const,
                text: JSON.stringify({ success: false, blocked: true, reason: execCtx.blockReason, _context: execCtx.recentContext }, null, 2),
              }],
            };
          }
    
          const preHash = await capturePreActionState(resolved);
          const result = await closeApp(package_name, device_id);
          invalidateCaches(resolved);
          const verification = await verifyAction('close_app', resolved, preHash);
    
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify({

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/divineDev-dotcom/android_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server