list_processes
List all currently running processes to identify and manage system tasks.
Instructions
List processes
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| random_string | Yes |
Implementation Reference
- src/tools/terminal_tools.js:349-380 (handler)The handler function that lists all running processes using the 'ps-list' npm package. It sorts processes by CPU usage, formats the top 50 with pid, name, cpu%, memory, ppid, and cmd, and returns them.
async function listProcesses() { try { // Dynamic import for ES module ps-list const psList = (await import('ps-list')).default; const processes = await psList(); // Sort by CPU usage processes.sort((a, b) => (b.cpu || 0) - (a.cpu || 0)); // Format the output const formattedProcesses = processes.slice(0, 50).map(proc => ({ pid: proc.pid, name: proc.name, cpu: proc.cpu ? `${proc.cpu.toFixed(1)}%` : '0.0%', memory: proc.memory ? `${(proc.memory / 1024 / 1024).toFixed(1)} MB` : '0.0 MB', ppid: proc.ppid, cmd: proc.cmd })); return { success: true, processes: formattedProcesses, total: processes.length, showing: formattedProcesses.length }; } catch (error) { logger.error(`Error listing processes: ${error.message}`); return { success: false, message: error.message }; - src/mcp/server.js:101-101 (registration)Registration of the 'list_processes' tool in the MCP server's tool list, defining its name, description, and input schema (a dummy required field).
{ name:'list_processes', description:'List processes', inputSchema:{ type:'object', properties:{ random_string:{type:'string'} }, required:['random_string'] } }, - src/mcp/server.js:263-263 (handler)Dispatch case in the MCP server's main switch statement that calls terminalTools.listProcesses() when the tool is invoked.
case 'list_processes': data = await terminalTools.listProcesses(); break; - src/tools/terminal_tools.js:466-466 (helper)Export of the listProcesses function from the terminal_tools module, making it available to the MCP server via require.
listProcesses,