Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

get_system_health

Check the health status of your Domoticz system and connected hardware gateways to quickly identify issues.

Instructions

Check the health of the Domoticz system and hardware gateways.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'get_system_health' tool. It queries Domoticz hardware gateways and checks device responsiveness (last update > 24h). Returns a JSON report with hardware health status, unresponsive device count, and a recommendation.
    @mcp.tool()
    async def get_system_health() -> str:
        """Check the health of the Domoticz system and hardware gateways."""
        async with create_client() as client:
            hw_resp = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=gethardware")
            hardware = hw_resp.json().get("result", [])
            
            health_report = []
            for hw in hardware:
                status = "Online" if hw.get("Enabled") == "true" else "Disabled"
                health_report.append({
                    "Name": hw.get("Name"),
                    "Type": hw.get("Type"),
                    "Status": status,
                    "Address": hw.get("Address"),
                    "Port": hw.get("Port")
                })
                
            # Check for unresponsive devices (last update > 24h)
            devices = await _get_cached_data(client, _device_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getdevices&filter=all&used=true")
            now = datetime.now()
            unresponsive_count = 0
            for dev in devices:
                last_update_str = dev.get("LastUpdate")
                if last_update_str:
                    try:
                        last_update = datetime.strptime(last_update_str, "%Y-%m-%d %H:%M:%S")
                        if now - last_update > timedelta(hours=24):
                            unresponsive_count += 1
                    except ValueError:
                        continue
                        
            return json.dumps({
                "status": "OK", 
                "result": {
                    "hardware_health": health_report,
                    "unresponsive_devices_count": unresponsive_count,
                    "recommendation": "Use `get_connectivity_report` for a detailed list of unresponsive devices." if unresponsive_count > 0 else "System looks healthy."
                }
            })
  • The tool is registered as an MCP tool using the @mcp.tool() decorator on line 444.
    @mcp.tool()
    async def get_system_health() -> str:
  • The DomoticzClient helper class (create_client) used by get_system_health for HTTP requests with OAuth/Basic auth support.
    class DomoticzClient:
        def __init__(self, own_client: bool = False):
            self._own_client = own_client
            if own_client or _global_http_client is None:
                self.client: httpx.AsyncClient = httpx.AsyncClient(timeout=30.0)
                self._owns_client = True
            else:
                self.client = _global_http_client
                self._owns_client = False
    
        async def __aenter__(self) -> "httpx.AsyncClient":
            oauth_token = None
    
            if DOMOTICZ_CLIENT_ID:
                oauth_token = await _fetch_oauth_token()
    
            if oauth_token:
                self.client.headers["Authorization"] = f"Bearer {oauth_token}"
            elif DOMOTICZ_USERNAME and DOMOTICZ_PASSWORD:
                self.client.auth = (DOMOTICZ_USERNAME, DOMOTICZ_PASSWORD)
            else:
                self.client.headers.pop("Authorization", None)
                self.client.auth = None
    
            return self.client
    
        async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
            if self._owns_client:
                await self.client.aclose()
    
    
    def create_client(own_client: bool = False) -> DomoticzClient:
        """Create a DomoticzClient instance.
    
        Args:
            own_client: If True, creates a dedicated client that will be closed on exit.
                        If False (default), uses a shared client for connection pooling.
        """
        return DomoticzClient(own_client=own_client)
    
    
    async def close_global_client() -> None:
  • The _get_cached_data helper used to fetch and cache devices list for the unresponsive device check.
    async def _get_cached_data(client: "httpx.AsyncClient", cache_obj: Dict[str, Any], api_url: str, key_path: str = "result") -> List[Dict[str, Any]]:
        now = time.time()
        if cache_obj["data"] is None or (now - cache_obj["timestamp"]) > CACHE_TTL:
            response = await _do_request(client, "GET", api_url)
            cache_obj["data"] = response.json().get(key_path, [])
            cache_obj["timestamp"] = now
        return cache_obj["data"]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It only says 'check the health' without disclosing if the operation is read-only, what resources are affected, or any permissions needed. Behavioral traits are largely absent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no extraneous content. It is appropriately front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite an output schema existing, the description fails to provide context about what the health report contains or how it differs from similar tools. The agent lacks sufficient information to understand the tool's output or scope fully.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters and 100% schema coverage, so baseline is 4. The description adds no additional parameter info, which is acceptable since none exist.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool checks health of the Domoticz system and hardware gateways. It distinguishes from sibling tools like get_system_status by specifying 'hardware gateways', but the exact scope isn't fully detailed.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like get_system_status or get_connectivity_report. The agent is left to infer context without explicit when-to-use or when-not-to-use instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/adrighem/domoticz-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server