get_system_uptime_tool
Retrieve system uptime and boot information to monitor server availability and track system restart history.
Instructions
Retrieve system uptime and boot information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/system_info_mcp/server.py:82-86 (handler)Handler function for the 'get_system_uptime_tool' tool, registered via @app.tool() decorator. It delegates the core logic to the get_system_uptime helper function.@app.tool() def get_system_uptime_tool() -> Dict[str, Any]: """Retrieve system uptime and boot information.""" return get_system_uptime()
- src/system_info_mcp/tools.py:350-366 (helper)Core helper function implementing the system uptime logic using psutil.boot_time(). Computes uptime in seconds, formats it, and returns boot time in ISO format.@cache_result("system_uptime", ttl=30) def get_system_uptime() -> Dict[str, Any]: """Retrieve system uptime and boot information.""" try: boot_time = psutil.boot_time() current_time = time.time() uptime_seconds = int(current_time - boot_time) return { "boot_time": timestamp_to_iso(boot_time), "uptime_seconds": uptime_seconds, "uptime_formatted": format_uptime(uptime_seconds), } except Exception as e: logger.error(f"Error getting system uptime: {e}") raise