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"

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