API Reference / agent / tools / system /

restart.py

Restarting tuiml-mcp processes.

stdio MCP servers are spawned as child processes by their parent AI clients (Claude Desktop, Cursor, ...). When the child exits, every mainstream client respawns it on the next request. So "restart" really means "kill the running children and let the clients respawn them with the freshly installed code".

Used by both tuiml restart (CLI) and the tuiml_restart MCP tool.

Functions

Func

find_mcp_processes

Line 21
find_mcp_processes(exclude_self: bool=True) -> List[Dict]

Return a list of running tuiml-mcp processes.

Parameters

exclude_self
bool = True
When True, omit the current process so a tuiml_restart MCP call running inside one of the targets doesn't kill itself before returning a response.

Returns

procs
List[Dict]
One dict per process with keys pid (int), ppid (int), and command (str). Empty list on Windows or if ps fails.
Func

kill_mcp_processes

Line 68
kill_mcp_processes(procs: Optional[List[Dict]]=None, grace_seconds: float=2.0, include_self: bool=False, self_delay_seconds: float=0.5) -> Dict

Send SIGTERM to each tuiml-mcp process; SIGKILL after grace.

Parameters

procs
list of dict
Explicit list of process dicts to kill. If None, the function re-discovers running tuiml-mcp processes itself (excluding the current one).
grace_seconds
float = 2.0
How long to wait between SIGTERM and SIGKILL for each PID.
include_self
bool = False
If True, schedule a delayed self-exit AFTER killing other processes. Used by the MCP tool so the agent receives the response before the server dies.
self_delay_seconds
float = 0.5
Delay before the deferred self-exit (allows the caller to flush a response).

Returns

result
Dict
Dict with keys killed (list of PIDs successfully terminated), failed (list of dicts with pid and error), and self_exit_scheduled (bool).
Func

execute_restart

Line 156
execute_restart(**kwargs) -> Dict[str, Any]

Restart every running tuiml-mcp child process.

When called from an MCP context the current server is one of those children. We schedule a deferred self-exit (after a short delay) so this response can be flushed back to the agent before the process dies; the parent client (Claude Desktop, Cursor, …) will auto-respawn the child with the newly installed code on its next request.

Parameters

include_self
bool = True
Also schedule a deferred exit of the current server process (arrives via **kwargs).

Returns

result
dict
status ('success'), killed_other (count), failed, self_exit_scheduled and note.