Skip to main content
Glama
cbxss
by cbxss

launch_app

Launch an Android app by specifying its package name via ADB, returning the process ID (PID) after smart polling until the process is detected.

Instructions

Launch an app via adb and return its PID (smart wait - polls for process).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageYesApp package name (e.g., 'com.spotify.music')
activityNoSpecific activity to launch (optional)
device_idNoDevice ID (optional)
timeout_msNoTimeout for waiting for PID in ms (default: 10000)

Implementation Reference

  • The main handler that launches an app via adb shell (using 'am start' if activity specified, otherwise 'monkey'), polls for the PID with timeout, and returns the result.
    def launch_app(
        package: str,
        activity: str | None = None,
        device_id: str | None = None,
        timeout_ms: int = 10000,
    ) -> dict:
        """Launch app via adb and return its PID."""
        if activity:
            component = f"{package}/{activity}" if not activity.startswith(package) else activity
            output = adb_shell(["am", "start", "-n", component], device_id)
        else:
            output = adb_shell([
                "monkey", "-p", package,
                "-c", "android.intent.category.LAUNCHER", "1"
            ], device_id)
    
        try:
            pid = wait_for_pid(package, device_id, timeout_ms)
        except RuntimeError:
            pid = None
    
        return {
            "package": package,
            "activity": activity,
            "pid": pid,
            "output": output,
        }
  • The MCP Tool definition with input schema for launch_app: requires 'package', optional 'activity', 'device_id', and 'timeout_ms'.
    Tool(
        name="launch_app",
        description="Launch an app via adb and return its PID (smart wait - polls for process).",
        inputSchema={
            "type": "object",
            "properties": {
                "package": {"type": "string", "description": "App package name (e.g., 'com.spotify.music')"},
                "activity": {"type": "string", "description": "Specific activity to launch (optional)"},
                "device_id": {"type": "string", "description": "Device ID (optional)"},
                "timeout_ms": {"type": "integer", "description": "Timeout for waiting for PID in ms (default: 10000)"},
            },
            "required": ["package"],
        },
    ),
  • Routing logic in the call_tool dispatcher that maps the 'launch_app' tool name to the adb.launch_app handler function.
    elif name == "launch_app":
        return adb.launch_app(
            arguments["package"],
            arguments.get("activity"),
            arguments.get("device_id"),
            arguments.get("timeout_ms", 10000),
        )
  • Helper function that polls for the app's PID after launch, with a configurable timeout (default 10s). Used by launch_app to return the PID.
    def wait_for_pid(package: str, device_id: str | None, timeout_ms: int = 10000) -> int:
        """Poll for PID to appear after launching app."""
        start = time_module.time()
        while (time_module.time() - start) * 1000 < timeout_ms:
            pid_output = adb_shell(["pidof", package], device_id)
            if pid_output:
                return int(pid_output.split()[0])
            time_module.sleep(0.2)
        raise RuntimeError(f"Timeout waiting for {package} to start")
Behavior3/5

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

With no annotations, the description partially carries the burden. It mentions the 'smart wait' polling behavior and that it returns a PID, but does not disclose side effects, failure modes, or behavior if the app is already running or if the device is not connected.

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 description is a single sentence that is front-loaded with the key action and result, and every word adds value. No redundant information.

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

Completeness4/5

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

For a simple launch tool with no output schema, the description covers the main purpose and expected return value (PID). It lacks details on error handling or timeout behavior but is reasonably complete for its complexity.

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?

Schema coverage is 100% with all parameters described. The description adds 'smart wait' context but no additional semantics beyond what the schema already provides. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (launch), the resource (app), the method (adb), and the outcome (return PID). It distinguishes from sibling tools like 'stop_app' and 'spawn_and_attach' by focusing on launching an existing app and returning its process ID.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for usage ('via adb', 'return its PID', 'smart wait - polls for process'), but it does not explicitly mention when to use this tool versus alternatives like 'spawn_and_attach' or when not to use it.

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/cbxss/frida-mcp'

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