kill_process
Terminate stuck or hung processes using PID. Supports graceful termination with timeout or forced kill for unresponsive processes.
Instructions
Terminate a process by PID with graceful or forced termination.
This tool allows terminating stuck or hung processes to clean up system resources. It supports both graceful termination (SIGTERM/WM_CLOSE) with a timeout, and forced termination (SIGKILL/TerminateProcess) for unresponsive processes.
Args: pid: Process ID to terminate (must be >= 1) force: If True, forcefully kill the process. If False, attempt graceful termination with timeout. Default: False timeout_seconds: Timeout in seconds to wait for graceful termination. Ignored if force=True. Range: 0.1-30.0s. Default: 5.0s ctx: MCP context for logging (optional)
Returns: KillProcessOutput with success status, PID, message, timing, and whether forced termination was used
Raises: SanitizedError: If process termination fails or is not enabled
Security: - Requires PROCEXEC_ENABLE_KILL=true environment variable to function - Handles permission errors gracefully (no crashes) - Cannot terminate system-critical processes (OS protection) - Error messages are sanitized (no sensitive info)
Examples: >>> # Graceful termination >>> result = await kill_process(pid=1234, force=False, timeout_seconds=5.0) >>> print(result.success, result.message) True 'Process terminated gracefully'
>>> # Forced termination
>>> result = await kill_process(pid=5678, force=True)
>>> print(result.success, result.forced)
True True
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes | ||
| force | No | ||
| timeout_seconds | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes | Process ID that was targeted for termination | |
| forced | Yes | Whether forced termination (SIGKILL) was used | |
| message | Yes | Human-readable status message describing the outcome | |
| success | Yes | Whether the process was successfully terminated | |
| termination_time_ms | Yes | Time taken to terminate the process in milliseconds |