process_kill
Terminate a specific process by its PID using the kill-process-mcp server, enabling direct and efficient process management across Windows, macOS, and Linux systems.
Instructions
Kill the process identified by the given PID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ctx | No | ||
| pid | Yes |
Implementation Reference
- kill_process_mcp.py:228-245 (handler)The handler function for the 'process_kill' tool. It uses psutil to kill the process with the given PID, includes safety checks (refuses to kill self), logging via ctx, and error handling for no such process or access denied.@mcp.tool() async def process_kill(pid: int, ctx: Context | None = None) -> str: """Kill the process identified by the given PID""" if ctx: await ctx.info(f"process_kill called pid={pid}") if pid == os.getpid(): return "Refusing to kill MCP server process" try: proc = psutil.Process(pid) proc.kill() proc.wait(timeout=5) return f"Process {pid} terminated" except (psutil.NoSuchProcess, psutil.AccessDenied) as err: return f"Failed to kill {pid}: {err}"