analyze_system_stability
Evaluate Windows system stability by analyzing event logs, crash data, and uptime history. Provides actionable recommendations based on a specified time frame, defaulting to the past 30 days.
Instructions
Analyze system stability and provide recommendations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| daysBack | No | Number of days back to analyze (default: 30) |
Implementation Reference
- src/tools/diagnostics.ts:80-138 (handler)The core handler function that executes the analyze_system_stability tool. It runs a PowerShell diagnostic script, computes a stability score based on BSOD events, shutdowns, crashes, hardware errors, and uptime, then generates a markdown report with rating, issues, recommendations, and metrics.export async function analyzeSystemStability(args: { daysBack?: number }) { const daysBack = args?.daysBack || 30; const result = await runPowerShellScript(DIAGNOSTIC_SCRIPT, { DaysBack: daysBack, JsonOutput: true }) as AllTypes.DiagnosticResults; const bsodCount = result.BSODEvents.length; const unexpectedShutdowns = result.ShutdownEvents.filter((e: AllTypes.EventInfo) => e.EventID === 6008).length; const totalCrashes = result.Summary.TotalApplicationCrashes || 0; const hardwareErrors = result.HardwareErrors.length; let stabilityScore = 100; const recommendations: string[] = []; const issues: string[] = []; if (bsodCount > 0) { stabilityScore -= bsodCount * 20; issues.push(`${bsodCount} BSOD event(s)`); recommendations.push('Investigate BSOD causes - check Windows Update for driver updates'); } if (unexpectedShutdowns > 0) { stabilityScore -= unexpectedShutdowns * 10; issues.push(`${unexpectedShutdowns} unexpected shutdown(s)`); recommendations.push('Check hardware connections and power supply'); } if (totalCrashes > 10) { stabilityScore -= Math.min(totalCrashes, 30); issues.push(`${totalCrashes} application crashes`); recommendations.push('Run system file checker: sfc /scannow'); } if (hardwareErrors > 0) { stabilityScore -= hardwareErrors * 5; issues.push(`${hardwareErrors} hardware error(s)`); recommendations.push('Check hardware health and run memory diagnostics'); } if (result.SystemInfo.CurrentUptimeDays > 30) { stabilityScore -= 5; recommendations.push('Reboot system to apply updates and clear memory'); } stabilityScore = Math.max(0, stabilityScore); let stabilityRating: string; if (stabilityScore >= 90) stabilityRating = 'Excellent ✅'; else if (stabilityScore >= 75) stabilityRating = 'Good 👍'; else if (stabilityScore >= 50) stabilityRating = 'Fair ⚠️'; else stabilityRating = 'Poor ❌'; return { content: [ { type: 'text', text: `# System Stability Analysis (Last ${daysBack} days)\n\n## Overall Stability Score: ${stabilityScore}/100 (${stabilityRating})\n\n## Issues Detected\n${issues.length > 0 ? issues.map(issue => `- ${issue}`).join('\n') : '- No major issues detected ✅'}\n\n## Recommendations\n${recommendations.length > 0 ? recommendations.map(rec => `- ${rec}`).join('\n') : '- System appears stable, continue regular maintenance'}\n\n## Key Metrics\n- **BSOD Events**: ${bsodCount}\n- **Unexpected Shutdowns**: ${unexpectedShutdowns}\n- **Application Crashes**: ${totalCrashes}\n- **Hardware Errors**: ${hardwareErrors}\n- **Current Uptime**: ${result.SystemInfo.CurrentUptimeDays} days\n\n## Additional Actions\n- Run DISM health check: \`DISM /Online /Cleanup-Image /RestoreHealth\`\n- Check Windows Update for pending updates\n- Review Event Viewer for additional details\n- Consider hardware diagnostics if issues persist`, }, ], }; }
- src/index.ts:104-117 (schema)The input schema definition for the analyze_system_stability tool, registered in the ListTools response. Defines optional daysBack parameter with default 30.{ name: 'analyze_system_stability', description: 'Analyze system stability and provide recommendations', inputSchema: { type: 'object', properties: { daysBack: { type: 'number', description: 'Number of days back to analyze (default: 30)', default: 30, }, }, }, },
- src/index.ts:547-548 (registration)The registration/dispatch logic in the CallToolRequestSchema handler's switch statement that routes calls to the analyzeSystemStability function from diagnostics module.case 'analyze_system_stability': return await diagnostics.analyzeSystemStability(args as { daysBack?: number });