Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

rename_device

Rename any Domoticz device by specifying its IDX or existing name to assign a new identifier.

Instructions

Rename a device by IDX or its old Name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
new_nameYes
idxNo
old_nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The rename_device tool handler function. It takes new_name, idx (optional), and old_name (optional). Resolves the device by idx or old_name, sends a rename command to Domoticz via the API, invalidates the device cache, and returns the response.
    async def rename_device(new_name: str, idx: int | None = None, old_name: str | None = None) -> str:
        """Rename a device by IDX or its old Name."""
        if idx is None and old_name is None:
            return '{"status": "error", "message": "Must provide either idx or old_name"}'
        async with create_client() as client:
            resolved_idx = await _resolve_device_idx(client, idx, old_name)
            if resolved_idx is None:
                return '{"status": "error", "message": "Device not found"}'
            response = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=renamedevice&name={urllib.parse.quote(new_name)}&idx={resolved_idx}")
            _device_cache["timestamp"] = 0 # Invalidate cache
            return response.text
  • The @mcp.tool() decorator registers rename_device as an MCP tool, making it discoverable and callable by the MCP protocol.
    async def rename_device(new_name: str, idx: int | None = None, old_name: str | None = None) -> str:
  • The function signature serves as the input schema. Parameters: new_name (str, required), idx (int, optional), old_name (str, optional). The docstring 'Rename a device by IDX or its old Name' acts as the tool description.
    @mcp.tool()
    async def rename_device(new_name: str, idx: int | None = None, old_name: str | None = None) -> str:
  • The _resolve_device_idx helper is used by rename_device to convert an optional name or idx into a resolved device idx by looking up the device cache.
    async def _resolve_device_idx(client: "httpx.AsyncClient", idx: Optional[int] = None, name: Optional[str] = None) -> Optional[int]:
        """Resolve a device to its idx."""
        return await _resolve_idx(client, idx, name, _device_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getdevices&filter=all&used=true")
  • The generic _resolve_idx helper function used for resolving entity names to idx values. It either returns the provided idx or looks up the name in cached data.
    async def _resolve_idx(
        client: "httpx.AsyncClient",
        idx: Optional[int],
        name: Optional[str],
        cache: Dict[str, Any],
        api_url: str
    ) -> Optional[int]:
        """Resolve an entity to its idx by either using the provided idx or looking up by name."""
        if idx is not None:
            return idx
        if not name:
            return None
        items = await _get_cached_data(client, cache, api_url)
        for item in items:
            if item.get("Name", "").lower() == name.lower():
                return int(str(item.get("idx")))
        return None
Behavior3/5

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

With no annotations, the description bears the full burden. It explains the identification methods but fails to disclose side effects, error behavior, or whether the operation is reversible. The description is adequate but lacks depth.

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

Conciseness3/5

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

The description is a single sentence and concise, but it sacrifices necessary detail for brevity, leading to gaps in clarity.

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?

The description covers the basic rename function but omits details like error cases, behavior when both identifiers are given, and any potential conflicts. An output schema exists, but the description does not refer to it or provide sufficient context for safe invocation.

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

Parameters2/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 must compensate. It explains that 'idx' and 'old_name' are alternative identifiers, but provides no constraints (e.g., uniqueness, format) on 'new_name' or behavior when both identifiers are provided or missing.

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 action 'rename' and the resource 'device', and specifies the alternative identification methods 'by IDX or its old Name', which distinguishes it from sibling tools like 'delete_device' and 'update_device_value'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives the identification methods but provides no guidance on when to use this tool versus other device modification tools, nor does it mention any prerequisites or conditions for renaming.

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