Skip to main content
Glama
Nam0101

android-mcp-toolkit

Get current activity/window focus

get-current-activity

Identify the currently focused app or window on an Android device by inspecting dumpsys window output.

Instructions

Inspect current focused app/window via dumpsys window.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeoutMsNoTimeout per adb call in milliseconds

Implementation Reference

  • Handler function for 'get-current-activity' tool. Runs 'adb shell dumpsys window', filters for mCurrentFocus/mFocusedApp lines, and returns up to 8 lines of focus info.
      async (params) => {
        const dump = await runAdbCommand(['shell', 'dumpsys', 'window'], params.timeoutMs);
        const lines = dump.split('\n').filter(line => line.includes('mCurrentFocus') || line.includes('mFocusedApp'));
        const trimmed = lines.slice(0, 8).join('\n').trim();
        return { content: [{ type: 'text', text: trimmed || 'No focus info found.' }] };
      }
    );
  • Input schema (zod) for 'get-current-activity': optional timeoutMs parameter (1000-15000ms, default 5000).
    const currentActivityInputSchema = z.object({
      timeoutMs: z.number().int().min(1000).max(15000).default(5000).describe('Timeout per adb call in milliseconds')
    });
  • Registration of 'get-current-activity' tool via server.registerTool() with title, description, inputSchema, and handler.
    server.registerTool(
      'get-current-activity',
      {
        title: 'Get current activity/window focus',
        description: 'Inspect current focused app/window via dumpsys window.',
        inputSchema: currentActivityInputSchema
      },
      async (params) => {
        const dump = await runAdbCommand(['shell', 'dumpsys', 'window'], params.timeoutMs);
        const lines = dump.split('\n').filter(line => line.includes('mCurrentFocus') || line.includes('mFocusedApp'));
        const trimmed = lines.slice(0, 8).join('\n').trim();
        return { content: [{ type: 'text', text: trimmed || 'No focus info found.' }] };
      }
    );
  • Helper function runAdbCommand that executes adb commands with timeout, used by the handler to run 'dumpsys window'.
    async function runAdbCommand(args, timeoutMs) {
      try {
        const { stdout } = await execFileAsync('adb', args, {
          timeout: timeoutMs,
          maxBuffer: 5 * 1024 * 1024
        });
        return stdout.trimEnd();
      } catch (error) {
        const stderr = error && typeof error.stderr === 'string' ? error.stderr.trim() : '';
        const message = [`adb ${args.join(' ')} failed`, error.message].filter(Boolean).join(': ');
        if (stderr) {
          throw new Error(`${message} | stderr: ${stderr}`);
        }
        throw new Error(message);
      }
    }
Behavior2/5

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

With no annotations, the description must disclose behavioral traits. It mentions 'inspect' and 'dumpsys window' but does not state side effects (likely none), read-only nature, permission requirements, or reliability. The agent cannot infer if this is safe or non-destructive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, front-loading the purpose efficiently. However, it omits necessary usage guidance and behavioral details, which reduces its completeness while maintaining conciseness.

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 simple tool with one optional parameter and no output schema, the description provides the core function but lacks usage context and behavioral transparency. It is minimally adequate but leaves gaps for an agent.

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%; the schema already describes timeoutMs with default, min, max. The description adds no parameter information beyond what the schema provides, so baseline score of 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 tool inspects the current focused app/window using 'dumpsys window'. The verb 'inspect' and resource 'current focused app/window' are specific. Sibling tools cover different functionalities (e.g., dump-ui-hierarchy gives UI tree), so this tool is well-differentiated.

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 on when to use this tool versus alternatives like dump-ui-hierarchy. The description does not specify prerequisites, typical use cases, or situations where this tool is preferable. The agent lacks context for tool 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/Nam0101/android-mcp-toolkit'

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