Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

add_user_variable

Add a new user variable to Domoticz by specifying its name, type, and initial value.

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 actual tool handler for add_user_variable. Registered with @mcp.tool(), it sends a GET request to Domoticz API with 'adduservariable' command, passing name, vtype, and value. Also invalidates the user variable cache so subsequent reads get fresh data.
    @mcp.tool()
    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
  • Registration of add_user_variable as an MCP tool via the @mcp.tool() decorator on line 717.
    @mcp.tool()
  • Input schema defined via type hints (name: str, vtype: int, value: str) and docstring that documents the vtype parameter values (0-4).
    @mcp.tool()
    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
  • Uses the helper function create_client() for HTTP client lifecycle and _do_request() for authenticated request handling with OAuth token refresh retry.
    @mcp.tool()
    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 cache that stores user variables data; add_user_variable invalidates this cache by resetting its timestamp to 0.
    _user_variable_cache = {"data": None, "timestamp": 0}
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It only documents the vtype enum but omits critical details like what happens if the variable already exists, permission requirements, or error conditions. This leaves significant behavioral ambiguity.

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 extremely concise (three lines) with front-loaded purpose. Every sentence is necessary: the first states the action, and the following two provide essential enum details. No wasted words.

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 no annotations, 3 parameters, and an output schema (whose content is unknown), the description lacks crucial context about return values, errors, input validation rules, or side effects. It fails to provide a complete picture for a mutation tool.

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?

Schema description coverage is 0%, so the description must add meaning. It does provide the vtype enum mapping (0-4) with formats for date/time. However, it offers no additional context for the 'name' and 'value' parameters beyond their types. This partial improvement is insufficient to reach the baseline 4 for a 0% coverage case.

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.' This is specific and distinct from sibling tools like delete_user_variable, update_user_variable, or get_user_variables, making the purpose immediately clear.

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, nor any prerequisites or scenarios. It lacks explicit usage context such as whether variables must be created before updating or if duplicates are allowed.

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