Skip to main content
Glama
Nam0101

android-mcp-toolkit

get-current-activity

Retrieve the currently focused Android app or window activity using ADB's dumpsys command for development debugging and automation.

Instructions

Inspect current focused app/window via dumpsys window.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeoutMsNoTimeout per adb call in milliseconds

Implementation Reference

  • The handler function for the 'get-current-activity' tool. Executes 'adb shell dumpsys window', filters relevant lines about current focus, and returns trimmed output.
    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.' }] }; }
  • Registration of the 'get-current-activity' tool using server.registerTool, including metadata 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.' }] }; } );
  • Zod input schema for the 'get-current-activity' tool, defining the timeoutMs parameter.
    const currentActivityInputSchema = z.object({ timeoutMs: z.number().int().min(1000).max(15000).default(5000).describe('Timeout per adb call in milliseconds') });

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