get_system_uptime_tool
Retrieve system uptime and boot information from the System Information MCP Server to monitor server performance and diagnose issues.
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)The MCP tool handler for 'get_system_uptime_tool', decorated with @app.tool() for registration. Delegates 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-367 (helper)The core helper function implementing the system uptime logic using psutil.boot_time(), computing uptime in seconds, formatting it, and converting boot time to ISO.@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