process_manager
Manage Windows processes by listing, monitoring, killing, and analyzing resource usage to optimize system performance and troubleshoot issues.
Instructions
Comprehensive process management including listing processes, getting process details, killing processes, and monitoring resource usage
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | The process management action to perform | |
| process_id | No | Process ID for specific process operations | |
| process_name | No | Process name for searching or filtering | |
| sort_by | No | Sort processes by specified criteria (default: cpu) | cpu |
| limit | No | Limit number of results (default: 20) | |
| include_system | No | Include system processes (default: true) |
Implementation Reference
- src/tools/process.ts:45-79 (handler)The main handler function for the process_manager tool. It takes input arguments, switches on the 'action' parameter, and delegates to specific helper methods for process listing, details, killing, etc. Handles errors by returning an error response.async run(args: { action: string; process_id?: number; process_name?: string; sort_by?: string; limit?: number; include_system?: boolean; }) { try { switch (args.action) { case "list_processes": return await this.listProcesses(args.sort_by, args.limit, args.include_system); case "get_process_details": return await this.getProcessDetails(args.process_id, args.process_name); case "kill_process": return await this.killProcess(args.process_id, args.process_name); case "find_process": return await this.findProcess(args.process_name!); case "get_top_processes": return await this.getTopProcesses(args.sort_by, args.limit); case "get_process_tree": return await this.getProcessTree(); default: throw new Error(`Unknown action: ${args.action}`); } } catch (error: any) { return { content: [{ type: "text", text: `❌ Process management operation failed: ${error.message}` }], isError: true }; } },
- src/tools/process.ts:9-43 (schema)Input schema defining the parameters for the process_manager tool, including required 'action' and optional fields like process_id, sort_by, etc.parameters: { type: "object", properties: { action: { type: "string", enum: ["list_processes", "get_process_details", "kill_process", "find_process", "get_top_processes", "get_process_tree"], description: "The process management action to perform" }, process_id: { type: "number", description: "Process ID for specific process operations" }, process_name: { type: "string", description: "Process name for searching or filtering" }, sort_by: { type: "string", enum: ["cpu", "memory", "name", "pid"], description: "Sort processes by specified criteria (default: cpu)", default: "cpu" }, limit: { type: "number", description: "Limit number of results (default: 20)", default: 20 }, include_system: { type: "boolean", description: "Include system processes (default: true)", default: true } }, required: ["action"] },
- src/index.ts:32-36 (registration)Registration of the process_manager tool in the ListToolsRequestSchema handler, providing name, description, and inputSchema.{ name: processManagerTool.name, description: processManagerTool.description, inputSchema: processManagerTool.parameters },
- src/index.ts:73-74 (registration)Tool call dispatching in the CallToolRequestSchema handler: switches on tool name and calls processManagerTool.run().case "process_manager": return await processManagerTool.run(args as any);
- src/tools/process.ts:81-98 (helper)Helper method to list processes, sorted by criteria, with limits and system process filtering, using PowerShell commands.async listProcesses(sortBy = "cpu", limit = 20, includeSystem = true) { try { const sortProperty = this.getSortProperty(sortBy); const systemFilter = includeSystem ? "" : "| Where-Object {$_.SessionId -ne 0}"; const command = `Get-Process ${systemFilter} | Sort-Object ${sortProperty} -Descending | Select-Object -First ${limit} Name, Id, CPU, WorkingSet, VirtualMemorySize, SessionId, StartTime | Format-Table -AutoSize`; const { stdout } = await execAsync(`powershell -Command "${command}"`); return { content: [{ type: "text", text: `# Process List\n\nSorted by: ${sortBy}\nLimit: ${limit}\nInclude System: ${includeSystem}\n\n\`\`\`\n${stdout}\n\`\`\`` }] }; } catch (error: any) { throw new Error(`Failed to list processes: ${error.message}`); }