Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

call_domoticz_api

Execute a generic Domoticz API call by specifying the action parameter and any additional query parameters to control or retrieve smart home data.

Instructions

Call a generic Domoticz API endpoint.

Args: param: The 'param' parameter of the JSON API (e.g. 'checkforupdate'). kwargs: Dictionary of additional query parameters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramYes
kwargsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler for the 'call_domoticz_api' MCP tool. It takes a 'param' string (the Domoticz JSON API param, e.g. 'checkforupdate') and a 'kwargs' dict of additional query parameters, constructs the URL, and calls the Domoticz API via GET request using the custom DomoticzClient.
    @mcp.tool()
    async def call_domoticz_api(param: str, kwargs: dict) -> str:
        """Call a generic Domoticz API endpoint.
        
        Args:
            param: The 'param' parameter of the JSON API (e.g. 'checkforupdate').
            kwargs: Dictionary of additional query parameters.
        """
        async with create_client() as client:
            url_params = urllib.parse.urlencode(kwargs)
            url = f"{DOMOTICZ_API_URL}?type=command¶m={param}"
            if url_params:
                url += f"&{url_params}"
            response = await _do_request(client, "GET", url)
            return response.text
  • The tool is registered as an MCP tool via the @mcp.tool() decorator on line 887, making it available in the tool registry.
    @mcp.tool()
  • The input schema for the tool: 'param' (str, required) and 'kwargs' (dict, required). The docstring explains the purpose: to call a generic Domoticz API endpoint.
    async def call_domoticz_api(param: str, kwargs: dict) -> str:
        """Call a generic Domoticz API endpoint.
        
        Args:
            param: The 'param' parameter of the JSON API (e.g. 'checkforupdate').
            kwargs: Dictionary of additional query parameters.
        """
  • The DomoticzClient helper (context manager) used by the handler to make authenticated HTTP requests to the Domoticz API.
    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:
  • Test file imports and tests the 'call_domoticz_api' function, providing a test case with 'testparam' and kwargs {'myarg': '1'}.
    async def test_new_tools():
        from domoticz_mcp.server import call_domoticz_api, check_for_updates, restart_system, get_camera_snapshot
Behavior2/5

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

With no annotations, the description should disclose behavioral traits like side effects, permissions, rate limits, or error handling. It only states it is a generic call, which is insufficient.

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

Conciseness4/5

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

The description is very concise with two short sentences. It is front-loaded but could include more information without being verbose.

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?

Given the tool's generic nature and the existence of many siblings, the description lacks information about response format, error handling, and appropriate usage contexts. The output schema is noted but not described.

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

Parameters3/5

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

The description adds meaning by explaining param as the API endpoint name (with example) and kwargs as additional query parameters. However, schema description coverage is 0%, so more detail would be beneficial.

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 states it calls a generic Domoticz API endpoint, which clearly distinguishes it from the many specific sibling tools. However, it could be more explicit about what range of API endpoints are available.

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 generic tool versus the many specialized sibling tools. The agent has no context to choose appropriately.

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