get_shutdown_events
Retrieve shutdown and reboot events from Windows system logs to diagnose system stability. Specify the number of days back to analyze for identifying historical shutdown patterns.
Instructions
Get only shutdown and reboot events
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| daysBack | No | Number of days back to analyze (default: 7) |
Implementation Reference
- src/tools/diagnostics.ts:33-47 (handler)The handler function implementing the core logic for the get_shutdown_events tool. It runs a PowerShell diagnostic script to retrieve shutdown events over a specified period and formats them into a markdown response.export async function getShutdownEvents(args: { daysBack?: number }) { const daysBack = args?.daysBack || 7; const result = await runPowerShellScript(DIAGNOSTIC_SCRIPT, { DaysBack: daysBack, JsonOutput: true }) as AllTypes.DiagnosticResults; return { content: [ { type: 'text', text: `# Shutdown and Reboot Events (Last ${daysBack} days)\n\n${result.ShutdownEvents.length > 0 ? result.ShutdownEvents.map((e: AllTypes.EventInfo) => `- **${e.Time}**: ${e.Description} (Event ID: ${e.EventID}, Source: ${e.Source})`).join('\n') : 'No shutdown/reboot events found in the specified period.'}\n\n**Total Events**: ${result.ShutdownEvents.length}\n**Unexpected Shutdowns**: ${result.ShutdownEvents.filter((e: AllTypes.EventInfo) => e.EventID === 6008).length}`, }, ], }; }
- src/index.ts:69-81 (schema)The input schema definition for the get_shutdown_events tool, registered in the ListTools handler, specifying the expected arguments.name: 'get_shutdown_events', description: 'Get only shutdown and reboot events', inputSchema: { type: 'object', properties: { daysBack: { type: 'number', description: 'Number of days back to analyze (default: 7)', default: 7, }, }, }, },
- src/index.ts:541-542 (registration)The registration and dispatch logic in the CallToolRequestSchema handler that routes calls to the getShutdownEvents function in diagnostics module.case 'get_shutdown_events': return await diagnostics.getShutdownEvents(args as { daysBack?: number });