UNPKG

it-tools-mcp

Version:

Full MCP 2025-06-18 compliant server with 121+ IT tools, logging, ping, progress tracking, cancellation, and sampling utilities

32 lines (31 loc) 1.11 kB
import psList from "ps-list"; export function registerPs(server) { server.registerTool("ps", { description: "List running processes", inputSchema: {}, // VS Code compliance annotations annotations: { title: "Ps", description: "List running processes", readOnlyHint: false } }, async () => { try { const processes = await psList(); // Defensive: handle missing properties and filter out bad entries const output = processes .map(p => { const pid = p.pid ?? 'N/A'; const name = p.name ?? 'N/A'; return `${pid}\t${name}`; }) .join("\n"); return { content: [{ type: "text", text: output || 'No processes found.' }] }; } catch (error) { // Log error for debugging console.error('ps error:', error); return { content: [{ type: "text", text: `ps failed: ${error instanceof Error ? error.message : error}` }] }; } }); }