list_processes
Monitor all active processes on your computer with detailed insights, including PID, command name, CPU, and memory usage. Ideal for system performance tracking.
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 running processes using platform-specific commands ('tasklist' on Windows, 'ps aux' on Unix-like), parses the output, and returns formatted process information (PID, command, CPU, memory).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)Tool registration in ListToolsRequestHandler: defines name, description, and empty input schema (no parameters 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 handler in CallToolRequestHandler switch statement that invokes the listProcesses function.case "list_processes": return listProcesses();
- src/server.ts:28-28 (registration)Import of the listProcesses handler function from process.ts.import { listProcesses, killProcess } from './tools/process.js';