performance
Monitor and analyze Windows system performance, including CPU, memory, disk, and network usage, and track top processes or specific performance counters in real-time.
Instructions
System performance monitoring including CPU usage, memory usage, disk I/O, network I/O, and system performance counters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | The performance monitoring action to perform | |
| counter_name | No | Specific performance counter name to query | |
| duration | No | Duration in seconds for monitoring (default: 10) | |
| interval | No | Interval in seconds between measurements (default: 1) | |
| process_count | No | Number of top processes to show (default: 10) |
Implementation Reference
- src/tools/performance.ts:41-82 (handler)Main handler function for the 'performance' tool. Dispatches to specific sub-methods based on the 'action' parameter (e.g., get_cpu_usage, get_memory_usage). Handles errors and returns formatted results.async run(args: { action: string; duration?: number; interval?: number; process_count?: number; counter_name?: string; }) { try { switch (args.action) { case "get_cpu_usage": return await this.getCpuUsage(args.duration); case "get_memory_usage": return await this.getMemoryUsage(); case "get_disk_usage": return await this.getDiskUsage(); case "get_disk_io": return await this.getDiskIO(); case "get_network_io": return await this.getNetworkIO(); case "get_system_performance": return await this.getSystemPerformance(); case "get_top_processes_by_cpu": return await this.getTopProcessesByCpu(args.process_count); case "get_top_processes_by_memory": return await this.getTopProcessesByMemory(args.process_count); case "get_performance_counters": return await this.getPerformanceCounters(args.counter_name); case "monitor_real_time": return await this.monitorRealTime(args.duration, args.interval); default: throw new Error(`Unknown action: ${args.action}`); } } catch (error: any) { return { content: [{ type: "text", text: `❌ Performance monitoring operation failed: ${error.message}` }], isError: true }; } },
- src/tools/performance.ts:10-39 (schema)Input schema defining the parameters for the performance tool, including required 'action' enum and optional parameters like duration, interval.parameters: { type: "object", properties: { action: { type: "string", enum: ["get_cpu_usage", "get_memory_usage", "get_disk_usage", "get_disk_io", "get_network_io", "get_system_performance", "get_top_processes_by_cpu", "get_top_processes_by_memory", "get_performance_counters", "monitor_real_time"], description: "The performance monitoring action to perform" }, duration: { type: "number", description: "Duration in seconds for monitoring (default: 10)", default: 10 }, interval: { type: "number", description: "Interval in seconds between measurements (default: 1)", default: 1 }, process_count: { type: "number", description: "Number of top processes to show (default: 10)", default: 10 }, counter_name: { type: "string", description: "Specific performance counter name to query" } }, required: ["action"] },
- src/index.ts:57-61 (registration)Registration of the 'performance' tool in the ListToolsRequestSchema handler, providing name, description, and input schema.{ name: performanceTool.name, description: performanceTool.description, inputSchema: performanceTool.parameters }
- src/index.ts:83-84 (registration)Dispatch/execution handler in the CallToolRequestSchema switch statement for the 'performance' tool.case "performance": return await performanceTool.run(args as any);
- src/tools/performance.ts:295-306 (helper)Utility helper function to format byte values into human-readable units (B, KB, MB, etc.), used in memory usage reporting.formatBytes(bytes: number): string { const units = ['B', 'KB', 'MB', 'GB', 'TB']; let size = bytes; let unitIndex = 0; while (size >= 1024 && unitIndex < units.length - 1) { size /= 1024; unitIndex++; } return `${size.toFixed(2)} ${units[unitIndex]}`; }