Skip to main content
Glama
rahulkr
by rahulkr

get_current_activity

Retrieve the currently focused Android app and activity for debugging, UI testing, or workflow automation.

Instructions

Get the currently focused app and activity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_serialNo

Implementation Reference

  • The main handler function for the 'get_current_activity' tool, decorated with @mcp.tool() for automatic registration in the MCP server. It executes ADB command to dump activity info, parses for the focused package/activity using regex, and returns a dict with package, activity, and full_component.
    @mcp.tool()
    def get_current_activity(device_serial: str | None = None) -> dict:
        """Get the currently focused app and activity"""
        output = run_adb(["shell", "dumpsys", "activity", "activities"], device_serial)
        
        result = {
            "package": None,
            "activity": None,
            "full_component": None
        }
        
        # Look for ResumedActivity or mFocusedActivity
        for line in output.split('\n'):
            if 'ResumedActivity' in line or 'mFocusedActivity' in line:
                match = re.search(r'([a-zA-Z0-9_.]+)/([a-zA-Z0-9_.]+)', line)
                if match:
                    result['package'] = match.group(1)
                    result['activity'] = match.group(2)
                    result['full_component'] = f"{match.group(1)}/{match.group(2)}"
                break
        
        return result
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions what the tool does ('Get the currently focused app and activity') but lacks details on permissions required, output format, error conditions, or side effects. For a tool with no annotation coverage, this is a significant gap in transparency.

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, clear sentence: 'Get the currently focused app and activity.' It's front-loaded with the core purpose, has zero wasted words, and is appropriately sized for a simple tool. Every part of the sentence earns its place by specifying the action and target.

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?

Given the tool's low complexity (1 optional parameter, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks context on behavior, output, or usage scenarios. For a tool with no annotations or output schema, it should provide more guidance to be fully complete, but it meets the bare minimum for a simple query tool.

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 1 parameter with 0% description coverage, but the parameter is optional (required parameters: 0). The description doesn't mention the parameter at all, which is acceptable since it's optional and the tool likely defaults to a primary device. With 0 required parameters, the baseline is 4, as the description needn't detail parameters that aren't essential for basic use.

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 tool's purpose: 'Get the currently focused app and activity.' It uses a specific verb ('Get') and identifies the resource ('currently focused app and activity'), which is distinct from sibling tools like 'get_app_info' or 'get_device_info.' However, it doesn't explicitly differentiate from siblings beyond the resource name.

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. It doesn't mention prerequisites (e.g., device connectivity), exclusions, or comparisons to similar tools like 'get_accessibility_info' or 'get_ui_hierarchy,' which might overlap in functionality. Usage is implied by the purpose but not explicitly stated.

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/rahulkr/r_adb_mcp_server'

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