get_temperature_info_tool
Retrieve real-time system temperature sensor data from the System Information MCP Server to monitor and analyze hardware thermal conditions.
Instructions
Retrieve system temperature sensors (when available).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/system_info_mcp/server.py:88-92 (registration)Registration of the get_temperature_info_tool via @app.tool() decorator. Thin wrapper that delegates execution to the core get_temperature_info helper function.@app.tool() def get_temperature_info_tool() -> Dict[str, Any]: """Retrieve system temperature sensors (when available).""" return get_temperature_info()
- src/system_info_mcp/tools.py:369-419 (handler)Core handler implementing the temperature information retrieval. Fetches temperature and fan sensor data using psutil.sensors_temperatures() and psutil.sensors_fans(). Includes caching, configuration check (enable_temperatures), and error handling.@cache_result("temperature_info", ttl=10) def get_temperature_info() -> Dict[str, Any]: """Retrieve system temperature sensors (when available).""" if not config.enable_temperatures: return {"temperatures": [], "fans": []} try: temperatures = [] fans = [] # Try to get temperature sensors try: if hasattr(psutil, 'sensors_temperatures'): sensors_temps = psutil.sensors_temperatures() if sensors_temps: for sensor_name, temps in sensors_temps.items(): for temp in temps: temp_info = { "name": temp.label or sensor_name, "current": round(temp.current, 1), "unit": "celsius", } if temp.high: temp_info["high"] = round(temp.high, 1) if temp.critical: temp_info["critical"] = round(temp.critical, 1) temperatures.append(temp_info) except (AttributeError, OSError) as e: logger.debug(f"Temperature sensors not available: {e}") # Try to get fan sensors try: if hasattr(psutil, 'sensors_fans'): sensors_fans = psutil.sensors_fans() if sensors_fans: for fan_name, fan_list in sensors_fans.items(): for fan in fan_list: fan_info = { "name": fan.label or fan_name, "current_speed": safe_int(fan.current), "unit": "rpm", } fans.append(fan_info) except (AttributeError, OSError) as e: logger.debug(f"Fan sensors not available: {e}") return {"temperatures": temperatures, "fans": fans} except Exception as e: logger.error(f"Error getting temperature info: {e}") raise