Skip to main content
Glama

android-mcp-toolkit

check-anr-state

Check recent ANR logs and monitor traces.txt to identify application not responding issues on Android devices, using ADB integration for debugging.

Instructions

Check recent ActivityManager ANR logs and tail /data/anr/traces.txt when accessible (best-effort, may require root/debuggable).

Input Schema

NameRequiredDescriptionDefault
maxLinesNoTail line count from ActivityManager:E
timeoutMsNoTimeout per adb call in milliseconds

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "properties": { "maxLines": { "default": 400, "description": "Tail line count from ActivityManager:E", "maximum": 2000, "minimum": 50, "type": "integer" }, "timeoutMs": { "default": 5000, "description": "Timeout per adb call in milliseconds", "maximum": 15000, "minimum": 1000, "type": "integer" } }, "type": "object" }

Implementation Reference

  • The main handler function that implements the logic for 'check-anr-state' tool. It fetches recent ActivityManager ANR logs and attempts to read status and tail of /data/anr/traces.txt, combining results with error handling.
    async params => { const sections = []; try { const amLogs = await runAdbCommand( ['logcat', '-d', '-t', String(params.maxLines), 'ActivityManager:E', '*:S'], params.timeoutMs ); if (amLogs) { sections.push('ActivityManager (recent):\n' + amLogs); } else { sections.push('ActivityManager (recent): no entries.'); } } catch (error) { sections.push(`ActivityManager: ${error.message}`); } try { const stat = await runAdbCommand(['shell', 'ls', '-l', '/data/anr/traces.txt'], params.timeoutMs); sections.push('traces.txt stat:\n' + stat); } catch (error) { sections.push(`traces.txt stat: ${error.message}`); } try { const tail = await runAdbCommand( ['shell', 'tail', '-n', '200', '/data/anr/traces.txt'], params.timeoutMs ); if (tail) { sections.push('traces.txt tail (200 lines):\n' + tail); } else { sections.push('traces.txt tail: empty.'); } } catch (error) { sections.push(`traces.txt tail: ${error.message}`); } return { content: [{ type: 'text', text: sections.join('\n\n') }] }; }
  • Zod input schema defining parameters for the 'check-anr-state' tool: maxLines for log tailing and timeoutMs.
    const anrStateInputSchema = z.object({ maxLines: z .number() .int() .min(50) .max(2000) .default(400) .describe('Tail line count from ActivityManager:E'), timeoutMs: z .number() .int() .min(1000) .max(15000) .default(5000) .describe('Timeout per adb call in milliseconds') });
  • The server.registerTool call that registers the 'check-anr-state' tool, providing its title, description, input schema, and handler function.
    server.registerTool( 'check-anr-state', { title: 'Check ANR state (ActivityManager + traces)', description: 'Check recent ActivityManager ANR logs and tail /data/anr/traces.txt when accessible (best-effort, may require root/debuggable).', inputSchema: anrStateInputSchema }, async params => { const sections = []; try { const amLogs = await runAdbCommand( ['logcat', '-d', '-t', String(params.maxLines), 'ActivityManager:E', '*:S'], params.timeoutMs ); if (amLogs) { sections.push('ActivityManager (recent):\n' + amLogs); } else { sections.push('ActivityManager (recent): no entries.'); } } catch (error) { sections.push(`ActivityManager: ${error.message}`); } try { const stat = await runAdbCommand(['shell', 'ls', '-l', '/data/anr/traces.txt'], params.timeoutMs); sections.push('traces.txt stat:\n' + stat); } catch (error) { sections.push(`traces.txt stat: ${error.message}`); } try { const tail = await runAdbCommand( ['shell', 'tail', '-n', '200', '/data/anr/traces.txt'], params.timeoutMs ); if (tail) { sections.push('traces.txt tail (200 lines):\n' + tail); } else { sections.push('traces.txt tail: empty.'); } } catch (error) { sections.push(`traces.txt tail: ${error.message}`); } return { content: [{ type: 'text', text: sections.join('\n\n') }] }; } );

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