Skip to main content
Glama

system_processes

Monitor and analyze top system processes by CPU or memory usage to identify resource consumption patterns and performance bottlenecks.

Instructions

List top processes sorted by CPU or memory usage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sort_byNo'cpu' or 'memory' (default: 'memory')
limitNoNumber of processes to show (default: 20)

Implementation Reference

  • The main handler function for the `system_processes` tool which executes the `ps` command to list processes.
    export async function listProcesses(args: Record<string, unknown>): Promise<string> {
      const sortBy = (args.sort_by as string) || "memory";
      const limit = (args.limit as number) || 20;
    
      const sortFlag = sortBy === "cpu" ? "-%cpu" : "-%mem";
    
      try {
        const { stdout } = await execFileAsync(
          "ps",
          ["aux", `--sort=${sortFlag}`],
          { timeout: 10000 }
        );
    
        const lines = stdout.trim().split("\n");
        const header = lines[0];
        const processes = lines.slice(1, limit + 1);
    
        return `Top ${processes.length} processes by ${sortBy}:\n\n${header}\n${processes.join("\n")}`;
      } catch (error: any) {
        throw new Error(`Failed to list processes: ${error.message}`);
      }
    }
  • The registration definition for the `system_processes` tool.
    {
      name: "system_processes",
      description: "List top processes sorted by CPU or memory usage",
      inputSchema: {
        type: "object" as const,
        properties: {
          sort_by: { type: "string", description: "'cpu' or 'memory' (default: 'memory')" },
          limit: { type: "number", description: "Number of processes to show (default: 20)" },
        },
      },
    },
  • The routing logic in `handleSystemTool` that maps the `system_processes` name to the `listProcesses` implementation.
    case "system_processes": return listProcesses(a);

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/batu-sonmez/infraclaude'

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