Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

delete_user_variable

Delete a user variable from Domoticz using its IDX or name. Removes the specified variable from the system.

Instructions

Delete a user variable by IDX or Name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idxNo
nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'delete_user_variable' tool handler function decorated with @mcp.tool(). It accepts an optional idx or name, resolves the user variable index, calls the Domoticz API to delete it, invalidates the cache, and returns the response.
    @mcp.tool()
    async def delete_user_variable(idx: int | None = None, name: str | None = None) -> str:
        """Delete a user variable by IDX or Name."""
        if idx is None and name is None:
            return '{"status": "error", "message": "Must provide either idx or name"}'
        async with create_client() as client:
            resolved_idx = await _resolve_user_variable_idx(client, idx, name)
            if resolved_idx is None:
                return '{"status": "error", "message": "User variable not found"}'
            response = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=deleteuservariable&idx={resolved_idx}")
            _user_variable_cache["timestamp"] = 0 # Invalidate cache
            return response.text
  • The @mcp.tool() decorator registers 'delete_user_variable' as an MCP tool with the FastMCP instance.
    @mcp.tool()
  • Helper function '_resolve_user_variable_idx' resolves a user variable name to its idx by fetching cached user variables data and matching by name (case-insensitive).
    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")
  • Test that verifies the delete_user_variable tool works, including resolution by name and the API call with the correct idx.
    # delete_user_variable
    # Mock resolution first
    respx.get(f"{DOMOTICZ_API_URL}?type=command¶m=getuservariables").mock(
        return_value=Response(200, json={"result": [{"idx": "5", "Name": "DeleteMe"}]})
    )
    respx.get(f"{DOMOTICZ_API_URL}?type=command¶m=deleteuservariable&idx=5").mock(
        return_value=Response(200, json={"status": "OK"})
    )
    await delete_user_variable(name="DeleteMe")
Behavior2/5

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

With no annotations, the description carries full burden but only states the action. It does not disclose side effects (e.g., irreversibility), authorization requirements, or idempotency. The presence of an output schema is not explained.

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 sentence of 8 words, highly concise with no extraneous information. Every word is necessary.

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 presence of an output schema, the description does not hint at the return value. It also fails to address what happens when both parameters are provided or if the variable is not found. Completeness is insufficient for effective use.

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 coverage is 0%, so the description must compensate. It explains that the variable can be identified by 'IDX or Name', adding meaning beyond the schema's optional null defaults. However, it doesn't clarify that exactly one must be provided.

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 'Delete a user variable by IDX or Name' clearly states the action (delete) and the resource (user variable) with the identification method. It distinguishes from sibling tools like 'add_user_variable' and 'update_user_variable' through the verb and context.

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, such as updating instead of deleting, or what happens if the variable doesn't exist. The description lacks any usage context or prerequisites.

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