kill_process
Terminate a running Node.js process by specifying its Process ID to manage debugging sessions and free system resources.
Instructions
Kill a managed Node.js process
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes | Process ID to kill |
Implementation Reference
- src/index.ts:353-390 (handler)The handler function that executes the kill_process tool logic. It retrieves the managed process by PID, sends a SIGTERM signal to kill it, removes it from the managed processes map, and returns appropriate success or error messages.private async killProcess(args: { pid: number }) { const managedProcess = this.managedProcesses.get(args.pid); if (!managedProcess) { return { content: [ { type: "text", text: `Process ${args.pid} not found in managed processes`, }, ], isError: true, }; } try { managedProcess.process.kill("SIGTERM"); this.managedProcesses.delete(args.pid); return { content: [ { type: "text", text: `Killed process ${args.pid}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error killing process: ${error}`, }, ], isError: true, }; }
- src/index.ts:157-167 (schema)The tool schema definition in ListToolsRequestHandler, defining the input schema with a required 'pid' number parameter and description.{ name: "kill_process", description: "Kill a managed Node.js process", inputSchema: { type: "object", properties: { pid: { type: "number", description: "Process ID to kill" } }, required: ["pid"], }, },
- src/index.ts:247-248 (registration)The dispatch/registration in the CallToolRequestHandler switch statement that routes 'kill_process' calls to the killProcess handler method.case "kill_process": return await this.killProcess(args as { pid: number });