get_temperature_info_tool
Get system temperature sensor data to monitor hardware heat levels and prevent overheating.
Instructions
Retrieve system temperature sensors (when available).
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_temperature_info_tool"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/system_info_mcp/server.py:88-91 (handler)The tool handler/endpoint registered with FastMCP's @app.tool() decorator. It delegates to the get_temperature_info() function in tools.py.
@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)The core implementation that gathers temperature sensor data (using psutil.sensors_temperatures) and fan data (using psutil.sensors_fans), returning a dict with 'temperatures' and 'fans' arrays.
@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 - src/system_info_mcp/server.py:9-17 (registration)Import of get_temperature_info from the tools module, making it available for the tool handler.
from .tools import ( get_cpu_info, get_memory_info, get_disk_info, get_network_info, get_process_list, get_system_uptime, get_temperature_info, ) - src/system_info_mcp/tools.py:8-16 (helper)Imports used by get_temperature_info including cache_result (for caching), safe_int (for fan speed conversion), and logger.
from .utils import ( bytes_to_gb, bytes_to_mb, format_uptime, timestamp_to_iso, cache_result, safe_float, safe_int, filter_sensitive_cmdline, - src/system_info_mcp/tools.py:369-419 (schema)The function signature and return type (Dict[str, Any]) defines the output schema. Returns dict with two keys: 'temperatures' (list of temp objects with name/current/unit/high/critical) and 'fans' (list of fan objects with name/current_speed/unit).
@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