Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

get_user_variables

Retrieve all user variables defined in your Domoticz home automation system, enabling centralized access to custom data.

Instructions

Get all user variables.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `get_user_variables` async function is the MCP tool handler. It uses @mcp.tool() decorator to register as 'get_user_variables', takes no arguments, fetches cached user variables from the Domoticz API endpoint 'getuservariables', and returns a JSON response with status 'OK' and the result list.
    @mcp.tool()
    async def get_user_variables() -> str:
        """Get all user variables."""
        async with create_client() as client:
            vars = await _get_cached_data(client, _user_variable_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getuservariables")
            return json.dumps({"status": "OK", "result": vars})
  • The tool is registered via the @mcp.tool() decorator at line 716, which registers the function `get_user_variables` with the FastMCP server instance.
    @mcp.tool()
  • The `_get_cached_data` helper is used by the handler to fetch data from the Domoticz API with caching support. It checks the cache TTL (5 minutes) before making the actual HTTP request.
    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"]
  • The `_user_variable_cache` dictionary is used for caching user variables data with a TTL of 300 seconds (5 minutes).
    _user_variable_cache = {"data": None, "timestamp": 0}
  • The `_resolve_user_variable_idx` helper resolves a user variable by name to its idx, used by other user variable tools (update/delete).
    async def _resolve_user_variable_idx(client: "httpx.AsyncClient", idx: Optional[int] = None, name: Optional[str] = None) -> Optional[int]:
        """Resolve a user variable to its idx."""
        return await _resolve_idx(client, idx, name, _user_variable_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getuservariables")
Behavior3/5

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

No annotations are provided, so the description must carry the burden of behavioral disclosure. It implies a read-only operation ('Get'), but does not explicitly state the absence of side effects, authentication needs, or behavior when no variables exist. The description is minimally adequate for a simple retrieval.

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 consists of a single, front-loaded sentence that conveys the tool's purpose without extraneous information. Every word earns its place, making it highly concise and easy to parse.

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

Completeness4/5

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

Given the tool's simplicity (no parameters, output schema exists), the description is largely complete. It adequately tells the agent to retrieve all user variables. However, it could mention that the result is a list or that no filtering is available, but the output schema likely covers return structure.

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 zero parameters, and the schema description coverage is 100% (trivially). The description adds no additional parameter meaning, which is acceptable because there are no parameters to document. A score of 4 reflects the baseline for no-parameter tools.

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 'Get all user variables' clearly states the verb and resource. It distinguishes from sibling tools like add_user_variable, delete_user_variable, and update_user_variable by specifying retrieval rather than mutation. However, it does not elaborate on scope or filtering, missing an opportunity to further differentiate.

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?

The description provides no guidance on when to use this tool versus alternatives. For example, it does not mention that this tool retrieves all variables at once, or when to use update_user_variable for individual changes. Agents receive no contextual hints for decision-making.

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