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({
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'force-stop' is technically accurate for Android, the description lacks critical context about side effects (data loss, cleared state, background service termination) or requirements (root/ADB privileges).

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 single sentence is appropriately sized and front-loaded with the action verb. It contains zero redundancy or filler—every word earns its place by conveying the core operation.

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

Completeness3/5

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

For a two-parameter tool with complete schema documentation and no output schema, the description is minimally adequate. However, given the lack of annotations and the destructive nature of force-stopping processes, the description should disclose behavioral implications to be considered complete.

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?

With 100% schema description coverage, the baseline is 3. The description mentions 'by its package name' which aligns with the package_name parameter but adds no syntax details, format examples, or semantics for the optional device_id parameter beyond the schema.

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 clearly states the action (force-stop) and target (Android application) using a specific technical verb. It implicitly distinguishes from siblings like 'open_app' and 'uninstall_app' through the verb choice, though it doesn't explicitly name alternative tools.

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?

No guidance is provided on when to use this tool versus alternatives like 'open_app' or prerequisites such as requiring ADB access or device permissions. It fails to mention when force-stopping is appropriate versus other termination methods.

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

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