Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

add_user_variable

Create a custom user variable with specified name, type (integer, float, string, date, or time), and initial value for Domoticz smart home automation.

Instructions

Add a new user variable.

vtype (Variable Type): 0: Integer 1: Float 2: String 3: Date (DD/MM/YYYY) 4: Time (HH:MM)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
vtypeYes
valueYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `add_user_variable` async function is the handler that adds a new user variable via the Domoticz API. It takes `name` (str), `vtype` (int: 0=Integer, 1=Float, 2=String, 3=Date, 4=Time), and `value` (str). It calls the Domoticz JSON API with param=adduservariable and invalidates the user variable cache after the request.
    async def add_user_variable(name: str, vtype: int, value: str) -> str:
        """Add a new user variable. 
        
        vtype (Variable Type):
        0: Integer
        1: Float
        2: String
        3: Date (DD/MM/YYYY)
        4: Time (HH:MM)
        """
        async with create_client() as client:
            response = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=adduservariable&vname={name}&vtype={vtype}&vvalue={value}")
            _user_variable_cache["timestamp"] = 0 # Invalidate cache
            return response.text
  • The input schema is defined via the function signature and docstring: `name: str`, `vtype: int` (with documented enum values 0-4), and `value: str`. The output is the raw JSON response from the Domoticz API.
    async def add_user_variable(name: str, vtype: int, value: str) -> str:
        """Add a new user variable. 
        
        vtype (Variable Type):
        0: Integer
        1: Float
        2: String
        3: Date (DD/MM/YYYY)
        4: Time (HH:MM)
        """
  • The tool is registered with the MCP framework via the `@mcp.tool()` decorator on line 723, which makes it available as an MCP tool named 'add_user_variable'.
    @mcp.tool()
  • The cache invalidation on line 736 (`_user_variable_cache['timestamp'] = 0`) is a helper mechanism to ensure subsequent reads of user variables fetch fresh data after adding a new variable.
    _user_variable_cache["timestamp"] = 0 # Invalidate cache
    return response.text
Behavior2/5

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

With no annotations, the description must fully disclose behavior, but it only details the vtype enumeration. It omits important traits like whether adding an existing variable overwrites or fails, permission requirements, or any side effects. This is insufficient for a mutation tool.

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 brief and front-loaded with the main purpose, followed by a clear enumeration of vtype values. However, it sacrifices completeness for brevity, missing details on other parameters. Still efficient overall.

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

Completeness3/5

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

Given the low complexity and presence of an output schema, the description covers the basics but lacks information on what happens upon success (e.g., return value), error handling, or prerequisites like variable name uniqueness. It is adequate but not thorough.

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 schema has 0% description coverage, so the description bears responsibility. It adds meaning for the 'vtype' parameter by listing valid values and formats, but provides no context for 'name' or 'value' (e.g., naming constraints or value formatting). This partial compensation yields a score of 3.

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

Purpose5/5

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

The description clearly states the tool's action ('Add a new user variable') with a specific verb and resource. It distinguishes itself from sibling tools like 'update_user_variable' and 'delete_user_variable' by focusing on creation.

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, such as 'update_user_variable' for existing variables. No contexts or exclusions are mentioned.

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