-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrestart_mcp.py
More file actions
25 lines (19 loc) · 745 Bytes
/
Copy pathrestart_mcp.py
File metadata and controls
25 lines (19 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import psutil
import os
def kill_mcp():
current_pid = os.getpid()
fastapi_pid = 32052 # From netstat
for proc in psutil.process_iter(["pid", "name", "cmdline"]):
try:
if proc.info["name"] == "python.exe":
pid = proc.info["pid"]
if pid == current_pid or pid == fastapi_pid:
continue
cmdline = proc.info["cmdline"]
if cmdline and any("mcp_server.py" in arg for arg in cmdline):
print(f"Killing MCP PID {pid}: {' '.join(cmdline)}")
proc.kill()
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
if __name__ == "__main__":
kill_mcp()