list_processes
View running processes on your computer to monitor system resources, identify active applications, and manage performance by checking PID, command names, CPU usage, and memory usage.
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 listProcesses function implements the core logic for listing running processes using platform-specific commands ('ps aux' on Unix, 'tasklist' on Windows), parses the output, and returns formatted text content.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 descriptor in the ListToolsRequestHandler, specifying the tool name, description, and empty input schema (no arguments 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 case in the CallToolRequestHandler switch statement that invokes the listProcesses handler when the tool is called.case "list_processes": return listProcesses();