process_manager
Manage Windows system processes effectively by listing, monitoring, or terminating them. Retrieve detailed process information, sort by CPU or memory usage, and organize process hierarchies for optimized system performance.
Instructions
Comprehensive process management including listing processes, getting process details, killing processes, and monitoring resource usage
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | The process management action to perform | |
| include_system | No | Include system processes (default: true) | |
| limit | No | Limit number of results (default: 20) | |
| 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 |
Input Schema (JSON Schema)
{
"properties": {
"action": {
"description": "The process management action to perform",
"enum": [
"list_processes",
"get_process_details",
"kill_process",
"find_process",
"get_top_processes",
"get_process_tree"
],
"type": "string"
},
"include_system": {
"default": true,
"description": "Include system processes (default: true)",
"type": "boolean"
},
"limit": {
"default": 20,
"description": "Limit number of results (default: 20)",
"type": "number"
},
"process_id": {
"description": "Process ID for specific process operations",
"type": "number"
},
"process_name": {
"description": "Process name for searching or filtering",
"type": "string"
},
"sort_by": {
"default": "cpu",
"description": "Sort processes by specified criteria (default: cpu)",
"enum": [
"cpu",
"memory",
"name",
"pid"
],
"type": "string"
}
},
"required": [
"action"
],
"type": "object"
}
Implementation Reference
- src/tools/process.ts:45-79 (handler)The main handler function for the process_manager tool that dispatches to action-specific helper methods based on the 'action' parameter.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 (parameters) defining the structure and validation for arguments to the process_manager tool.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 MCP server's list tools response.{ name: processManagerTool.name, description: processManagerTool.description, inputSchema: processManagerTool.parameters },
- src/index.ts:73-74 (registration)Dispatch/handling case for calling the process_manager tool in the MCP server's tool call handler.case "process_manager": return await processManagerTool.run(args as any);
- src/tools/process.ts:81-98 (helper)Example helper method for listing processes, sorted and filtered as specified.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}`); }