get_restart_events
Retrieve recent application restart and reload events with triggering files, including Rust backend rebuilds and frontend HMR updates for Tauri desktop app automation.
Instructions
Get recent app restart/reload events with the files that triggered them. Includes Rust rebuilds (backend) and HMR updates (frontend).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max events | |
| clear | No | Clear events after reading | |
| window | No | Window label for frontend HMR events (default: focused window) |
Implementation Reference
- Main handler implementation for get_restart_events. Merges Rust rebuild events from TauriManager and HMR updates from SocketManager, sorts by timestamp, limits results, and returns a summary with event counts.get_restart_events: async (args: { limit?: number; clear?: boolean; window?: string }) => { const limit = args.limit ?? 10; const clear = args.clear ?? false; const windowLabel = args.window; // Get Rust rebuild events from TauriManager const rustEvents = tauriManager.getRustRebuildEvents({ limit, clear }); // Get frontend HMR updates from socket if app is running let frontendEvents: Array<{ type: 'hmr-update' | 'full-reload'; files: string[]; timestamp: number }> = []; try { const hmrResult = await socketManager.getHmrUpdates(clear, windowLabel); frontendEvents = hmrResult.updates ?? []; } catch { // App not running or socket not available } // Merge and format all events const allEvents = [ ...rustEvents.map(e => ({ type: e.type, files: [e.file], timestamp: e.timestamp, source: 'backend' as const, })), ...frontendEvents.map(e => ({ type: e.type, files: e.files, timestamp: e.timestamp, source: 'frontend' as const, })), ]; // Sort by timestamp (most recent first) and limit allEvents.sort((a, b) => b.timestamp - a.timestamp); const limitedEvents = allEvents.slice(0, limit); return { content: [ { type: 'text' as const, text: JSON.stringify({ events: limitedEvents, summary: { total: limitedEvents.length, rustRebuilds: limitedEvents.filter(e => e.type === 'rust-rebuild').length, hmrUpdates: limitedEvents.filter(e => e.type === 'hmr-update').length, fullReloads: limitedEvents.filter(e => e.type === 'full-reload').length, }, }, null, 2), }, ], }; },
- Tool schema definition for get_restart_events using Zod. Defines input parameters: limit (max events), clear (clear after reading), and window (window label for frontend HMR events).get_restart_events: { name: 'get_restart_events', description: 'Get recent app restart/reload events with the files that triggered them. Includes Rust rebuilds (backend) and HMR updates (frontend).', inputSchema: z.object({ limit: z.number().optional().default(10).describe('Max events'), clear: z.boolean().optional().default(false).describe('Clear events after reading'), window: z.string().optional().describe('Window label for frontend HMR events (default: focused window)'), }), },
- packages/tauri-mcp/src/server.ts:112-134 (registration)MCP server registration for tool execution. Routes CallToolRequestSchema requests to the appropriate handler from toolHandlers, including get_restart_events.this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; if (!(name in this.toolHandlers)) { throw new Error(`Unknown tool: ${name}`); } const handler = this.toolHandlers[name as ToolName]; try { return await handler(args as never); } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${(error as Error).message}`, }, ], isError: true, }; } });
- Helper method in TauriManager that retrieves Rust rebuild events. Supports limiting results and optionally clearing the event list after retrieval.getRustRebuildEvents(options: { limit?: number; clear?: boolean } = {}): RustRebuildEvent[] { const { limit, clear = false } = options; const events = limit ? this.rustRebuildEvents.slice(-limit) : [...this.rustRebuildEvents]; if (clear) { this.rustRebuildEvents = []; } return events; }
- Helper method in SocketManager that retrieves HMR updates from the running app via socket connection. Returns updates with type, files, and timestamp.async getHmrUpdates(clear?: boolean, windowLabel?: string): Promise<{ updates: Array<{ type: 'hmr-update' | 'full-reload'; files: string[]; timestamp: number }>; }> { const params: Record<string, unknown> = { clear: clear ?? false }; if (windowLabel) params.window = windowLabel; const result = await this.sendCommand('get_hmr_updates', params); return result as { updates: Array<{ type: 'hmr-update' | 'full-reload'; files: string[]; timestamp: number }>; }; }