analyze_crash
Analyze Android and iOS crash logs to identify patterns and root causes. Supports live device analysis and iOS symbolication for debugging mobile applications.
Instructions
Analyze crash logs and device logs to identify crash patterns and root causes. Supports both Android (logcat) and iOS (crash files + oslog). For live device analysis, checks device logs automatically. For iOS, can also analyze .ips/.crash files with symbolication.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| platform | Yes | Target platform to analyze | |
| appId | No | App ID (Android package name or iOS bundle ID) for live device log analysis | |
| deviceId | No | Device ID for analysis (optional, uses first available device) | |
| crashLogPath | No | Path to iOS crash log file (.ips or .crash) - iOS only, optional for live analysis | |
| dsymPath | No | Path to dSYM file or directory - iOS only (optional, searches common locations) | |
| timeRangeSeconds | No | Time range in seconds to search device logs (default: 300 = 5 minutes) | |
| skipSymbolication | No | Skip symbolication for faster analysis - iOS only (default: false) | |
| includeRawLog | No | Include raw log data in output (default: false) |
Implementation Reference
- src/tools/crash/analyze-crash.ts:123-175 (handler)Core handler function that orchestrates the crash analysis logic for both Android and iOS platforms, including validation, platform dispatch, and sub-analysis calls.export async function analyzeCrash(args: AnalyzeCrashArgs): Promise<ExtendedCrashAnalysis> { const { platform, crashLogPath, appId, deviceId, dsymPath, timeRangeSeconds = 300, skipSymbolication = false, includeRawLog = false, } = args; const startTime = Date.now(); // Validate platform if (!isPlatform(platform)) { throw Errors.invalidArguments(`Invalid platform: ${platform}. Must be 'android' or 'ios'`); } const targetPlatform = platform as Platform; // Determine analysis mode if (targetPlatform === 'android') { // Android: Always use live device log analysis return analyzeAndroidCrash({ appId, deviceId, timeRangeSeconds, includeRawLog, startTime, }); } else { // iOS: Use crash log file if provided, otherwise live analysis if (crashLogPath) { return analyzeIOSCrashFile({ crashLogPath, dsymPath, bundleId: appId, skipSymbolication, includeRawLog, startTime, }); } else { return analyzeIOSDeviceLogs({ appId, deviceId, timeRangeSeconds, includeRawLog, startTime, }); } } }
- TypeScript interface defining the input schema/arguments for the analyze_crash tool.export interface AnalyzeCrashArgs { /** Target platform (required) */ platform: string; /** Path to the crash log file (.ips or .crash) - iOS only, optional for live analysis */ crashLogPath?: string; /** App ID (Android package name or iOS bundle ID) for live device log analysis */ appId?: string; /** Device ID for live device log analysis (optional, uses first available) */ deviceId?: string; /** Path to dSYM file or directory (optional, iOS only) */ dsymPath?: string; /** Time range in seconds to search logs (default: 300 = 5 minutes) */ timeRangeSeconds?: number; /** Skip symbolication (faster, less detailed) - iOS only */ skipSymbolication?: boolean; /** Include raw crash log in output */ includeRawLog?: boolean; }
- src/tools/crash/analyze-crash.ts:837-893 (registration)Registration function for the 'analyze_crash' tool, including detailed input schema (JSON) and the tool execution handler lambda.export function registerAnalyzeCrashTool(): void { getToolRegistry().register( 'analyze_crash', { description: 'Analyze crash logs and device logs to identify crash patterns and root causes. ' + 'Supports both Android (logcat) and iOS (crash files + oslog). ' + 'For live device analysis, checks device logs automatically. ' + 'For iOS, can also analyze .ips/.crash files with symbolication.', inputSchema: createInputSchema( { platform: { type: 'string', enum: ['android', 'ios'], description: 'Target platform to analyze', }, appId: { type: 'string', description: 'App ID (Android package name or iOS bundle ID) for live device log analysis', }, deviceId: { type: 'string', description: 'Device ID for analysis (optional, uses first available device)', }, crashLogPath: { type: 'string', description: 'Path to iOS crash log file (.ips or .crash) - iOS only, optional for live analysis', }, dsymPath: { type: 'string', description: 'Path to dSYM file or directory - iOS only (optional, searches common locations)', }, timeRangeSeconds: { type: 'number', description: 'Time range in seconds to search device logs (default: 300 = 5 minutes)', }, skipSymbolication: { type: 'boolean', description: 'Skip symbolication for faster analysis - iOS only (default: false)', }, includeRawLog: { type: 'boolean', description: 'Include raw log data in output (default: false)', }, }, ['platform'] ), }, async (args) => { const result = await analyzeCrash(args as unknown as AnalyzeCrashArgs); return { ...result, formattedOutput: formatAnalysisForAI(result), }; } ); }
- src/tools/register.ts:156-158 (registration)Import and invocation of the analyze_crash tool registration during overall tool registration in server startup.const { registerAnalyzeCrashTool } = await import('./crash/analyze-crash.js'); registerAnalyzeCrashTool();