list_processes
View all active processes and their details, including PID, command name, CPU usage, and memory usage, to monitor and manage system resources effectively.
Instructions
List all running processes.
Returns process information including PID, command name, CPU usage, and memory usage.
This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/process.ts:9-40 (handler)Core implementation of the list_processes tool. Executes platform-specific command ('tasklist' on Windows, 'ps aux' on Unix) to list processes, parses output to extract PID, command, CPU, and memory, and returns formatted text output.export async function listProcesses(): Promise<ServerResult> { 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) { return { content: [{ type: "text", text: `Error: Failed to list processes: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }
- src/server.ts:1225-1227 (registration)Dispatcher in CallToolRequest handler that routes 'list_processes' tool calls to the handleListProcesses function.case "list_processes": result = await handlers.handleListProcesses(); break;
- src/server.ts:904-916 (registration)Tool definition registered in ListToolsRequest handler, including name, description, input schema (referencing ListProcessesArgsSchema), and annotations.name: "list_processes", description: ` List all running processes. Returns process information including PID, command name, CPU usage, and memory usage. ${CMD_PREFIX_DESCRIPTION}`, inputSchema: zodToJsonSchema(ListProcessesArgsSchema), annotations: { title: "List Running Processes", readOnlyHint: true, }, },
- src/handlers/process-handlers.ts:15-17 (handler)Handler wrapper function that directly delegates to the core listProcesses implementation.export async function handleListProcesses(): Promise<ServerResult> { return listProcesses(); }
- src/tools/schemas.ts:18-18 (schema)Zod schema defining empty input arguments for list_processes tool (no parameters required).export const ListProcessesArgsSchema = z.object({});