Skip to main content
Glama

performance

Monitor Windows system performance by tracking CPU, memory, disk I/O, network activity, and performance counters to identify resource usage and bottlenecks.

Instructions

System performance monitoring including CPU usage, memory usage, disk I/O, network I/O, and system performance counters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesThe performance monitoring action to perform
durationNoDuration in seconds for monitoring (default: 10)
intervalNoInterval in seconds between measurements (default: 1)
process_countNoNumber of top processes to show (default: 10)
counter_nameNoSpecific performance counter name to query

Implementation Reference

  • The main execution handler for the 'performance' tool. It switches on the 'action' parameter to call specific performance monitoring methods.
    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
        };
      }
    },
  • Input schema (parameters) for the 'performance' tool, defining the action enum and supporting parameters.
    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.
    {
      name: performanceTool.name,
      description: performanceTool.description,
      inputSchema: performanceTool.parameters
    }
  • src/index.ts:83-84 (registration)
    Dispatch case in the CallToolRequestSchema handler that executes the 'performance' tool.
    case "performance":
      return await performanceTool.run(args as any);
  • Example helper function for getting CPU usage, one of the sub-handlers called by the main run method.
    async getCpuUsage(duration = 10) {
      try {
        // Get current CPU info
        const cpus = os.cpus();
        const cpuCount = cpus.length;
        const cpuModel = cpus[0].model;
        
        // Get CPU usage using PowerShell
        const command = `Get-Counter "\\Processor(_Total)\\% Processor Time" -SampleInterval 1 -MaxSamples ${duration} | Select-Object -ExpandProperty CounterSamples | Select-Object CookedValue | Measure-Object -Property CookedValue -Average -Maximum -Minimum`;
        const { stdout } = await execAsync(`powershell -Command "${command}"`);
        
        // Get per-core usage
        const coreCommand = `Get-Counter "\\Processor(*)\\% Processor Time" -MaxSamples 1 | Select-Object -ExpandProperty CounterSamples | Where-Object {$_.InstanceName -ne '_total'} | Select-Object InstanceName, CookedValue | Format-Table -AutoSize`;
        const { stdout: coreUsage } = await execAsync(`powershell -Command "${coreCommand}"`);
        
        const result = `# CPU Usage Analysis\n\n## CPU Information\n` +
          `- **Model**: ${cpuModel}\n` +
          `- **Cores**: ${cpuCount}\n` +
          `- **Monitoring Duration**: ${duration} seconds\n\n` +
          `## Overall CPU Usage Statistics\n\`\`\`\n${stdout}\n\`\`\`\n\n` +
          `## Per-Core Usage (Current)\n\`\`\`\n${coreUsage}\n\`\`\``;
        
        return {
          content: [{ type: "text", text: result }]
        };
      } catch (error: any) {
        throw new Error(`Failed to get CPU usage: ${error.message}`);
      }
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/guangxiangdebizi/windows-system-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server