list_processes
View all active processes on your computer with detailed information including PID, command name, CPU usage, and memory usage for system monitoring and management.
Instructions
List all running processes. Returns process information including PID, command name, CPU usage, and memory usage.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/process.ts:9-37 (handler)The handler function that lists processes using platform-specific commands (tasklist on Windows, ps aux on Unix), parses PID, command, CPU, and memory, and returns formatted text output.export async function listProcesses(): Promise<{content: Array<{type: string, text: string}>}> { const command = os.platform() === 'win32' ? 'tasklist' : 'ps aux'; try { const { stdout } = await execAsync(command); const processes = stdout.split('\n') .slice(1) .filter(Boolean) .map(line => { const parts = line.split(/\s+/); return { pid: parseInt(parts[1]), command: parts[parts.length - 1], cpu: parts[2], memory: parts[3], } as ProcessInfo; }); return { content: [{ type: "text", text: processes.map(p => `PID: ${p.pid}, Command: ${p.command}, CPU: ${p.cpu}, Memory: ${p.memory}` ).join('\n') }], }; } catch (error) { throw new Error('Failed to list processes'); } }
- src/server.ts:84-94 (registration)Registration of the list_processes tool in the ListTools response, including name, description, and empty input schema indicating no parameters are required.{ name: "list_processes", description: "List all running processes. Returns process information including PID, " + "command name, CPU usage, and memory usage.", inputSchema: { type: "object", properties: {}, required: [], }, },
- src/server.ts:230-231 (registration)Dispatch logic in the CallToolRequest handler that invokes the listProcesses function when the tool is called.case "list_processes": return listProcesses();