list_processes
Retrieve detailed information on all running processes, including PID, command name, CPU, and memory usage, for effective system monitoring and management using Desktop Commander MCP.
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)Core handler function that executes platform-specific command to list processes, parses output into ProcessInfo objects, formats as text lines, and returns MCP-standard content array.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)Registers the 'list_processes' tool in the MCP server's ListTools response, including name, detailed description, and empty input schema indicating 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 (handler)Dispatch logic in CallToolRequest handler that routes 'list_processes' tool calls directly to the listProcesses implementation.case "list_processes": return listProcesses();
- src/server.ts:89-93 (schema)Input schema definition for list_processes tool: empty object schema (no input parameters). Note: output follows standard MCP content format implicitly via handler.inputSchema: { type: "object", properties: {}, required: [], },