get_crash_logs
Retrieve crash and exception logs from Android devices to identify and debug application failures during development and testing.
Instructions
Get crash/exception logs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package_name | No | ||
| device_serial | No |
Implementation Reference
- src/adb_mcp_server/server.py:738-761 (handler)The handler function for the 'get_crash_logs' tool, decorated with @mcp.tool() for registration in the FastMCP server. It fetches the last 500 lines of logcat, filters for crash indicators like 'FATAL EXCEPTION', collects relevant log lines, and optionally filters by package_name.@mcp.tool() def get_crash_logs(package_name: str | None = None, device_serial: str | None = None) -> str: """Get crash/exception logs""" output = run_adb(["shell", "logcat", "-d", "-t", "500"], device_serial) # Look for crash indicators crash_keywords = ['FATAL EXCEPTION', 'AndroidRuntime', 'crash', 'Exception', 'Error'] log_lines = output.split('\n') crash_lines = [] in_crash = False for line in log_lines: if any(kw in line for kw in crash_keywords): in_crash = True if in_crash: crash_lines.append(line) if line.strip() == '' or len(crash_lines) > 50: in_crash = False if package_name: crash_lines = [l for l in crash_lines if package_name in l or 'at ' in l] return '\n'.join(crash_lines) if crash_lines else "No crash logs found"
- src/adb_mcp_server/server.py:738-738 (registration)The @mcp.tool() decorator registers the get_crash_logs function as an MCP tool.@mcp.tool()