Skip to main content
Glama

dump_current_activity

Retrieve the current activity name from a connected Android device for debugging and testing purposes.

Instructions

Dump the current activity name of the connected Android device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'dump_current_activity' MCP tool. It uses 'adb shell dumpsys activity activities' to retrieve activity information, parses the output to extract the current resumed activity name, and returns it as a string. This is also the registration point via the @mcp.tool() decorator.
    @mcp.tool()
    def dump_current_activity() -> str:
        """Dump the current activity name of the connected Android device"""
        result = subprocess.run(
            ["adb", "shell", "dumpsys", "activity", "activities"],
            capture_output=True,
            text=True,
        )
        if result.returncode != 0:
            raise RuntimeError(f"Error dumping current activity: {result.stderr}")
        
        # Parse the output to find the current activity
        output = result.stdout
        lines = output.splitlines()
        
        # Look for the "mResumedActivity" line which contains the current activity
        for line in lines:
            if "mResumedActivity" in line:
                # Extract activity name from the line
                # Format: mResumedActivity: ActivityRecord{...component=package.name/.ActivityName...}
                if "component=" in line:
                    component_part = line.split("component=")[1]
                    activity_name = component_part.split(" ")[0].split("}")[0]
                    return f"Current activity: {activity_name}"
        
        # Alternative: look for "Running activities" section and get the top one
        in_running_activities = False
        for line in lines:
            if "Running activities" in line:
                in_running_activities = True
                continue
            if in_running_activities and "ActivityRecord" in line and "state=RESUMED" in line:
                # Extract activity name from ActivityRecord line
                if " " in line and "/" in line:
                    parts = line.strip().split()
                    for part in parts:
                        if "/" in part and "." in part:
                            activity_name = part
                            return f"Current activity: {activity_name}"
        
        return "Current activity information not found in dumpsys output"
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. It states what the tool does but fails to describe key traits: it doesn't specify if this is a read-only operation, what permissions are needed, how it handles errors, or the format of the output. This leaves significant gaps for an agent to understand the tool's behavior.

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, efficient sentence that directly states the tool's purpose without any wasted words. It is front-loaded and appropriately sized for a simple tool with no parameters.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for a tool that interacts with a connected device. It doesn't explain what 'dump' entails (e.g., output format, potential side effects), error handling, or dependencies, leaving the agent with insufficient context for reliable use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't add parameter details, earning a baseline score of 4 for not introducing unnecessary information.

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 verb ('dump') and resource ('current activity name of the connected Android device'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'dump_ui_hierarchy' or 'list_apps', which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives, such as when to prefer 'dump_ui_hierarchy' for more detailed UI information or 'list_apps' for broader context. It lacks any mention of prerequisites, exclusions, or contextual cues for selection.

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/vs4vijay/espresso-mcp'

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