Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

control_blinds

Send open, close, or stop commands to control blinds or covers.

Instructions

Control blinds or covers.

Args: command: Must be 'Open', 'Close', or 'Stop'. idx: Device index. name: Device name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYes
idxNo
nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the control_blinds tool. It accepts 'command' ('Open', 'Close', or 'Stop'), resolves the device by idx or name, and sends a switchlight command to the Domoticz API.
    @mcp.tool()
    async def control_blinds(command: str, idx: int | None = None, name: str | None = None) -> str:
        """Control blinds or covers.
        
        Args:
            command: Must be 'Open', 'Close', or 'Stop'.
            idx: Device index.
            name: Device name.
        """
        if idx is None and name is None:
            return '{"status": "error", "message": "Must provide either idx or name"}'
        if command.capitalize() not in ['Open', 'Close', 'Stop']:
            return '{"status": "error", "message": "command must be \'Open\', \'Close\', or \'Stop\'"}'
        async with create_client() as client:
            resolved_idx = await _resolve_device_idx(client, idx, 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=switchlight&idx={resolved_idx}&switchcmd={command.capitalize()}")
            return response.text
  • Docstring and parameter schema for control_blinds. Defines the 'command' parameter (Open/Close/Stop) and optional idx/name parameters.
    async def control_blinds(command: str, idx: int | None = None, name: str | None = None) -> str:
        """Control blinds or covers.
        
        Args:
            command: Must be 'Open', 'Close', or 'Stop'.
            idx: Device index.
            name: Device name.
        """
  • The @mcp.tool() decorator registers control_blinds as an MCP tool.
    @mcp.tool()
  • Helper functions _resolve_idx and _resolve_device_idx used by control_blinds to resolve a device name or idx. These cache and look up devices from the Domoticz API.
    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"]
    
    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
    
    
    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")
Behavior2/5

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

No annotations are provided, so the description carries full burden. It does not disclose behavioral traits like idempotency, error handling for invalid commands, or prerequisites (e.g., device must exist). The description only states commands without explaining potential side effects or failure modes.

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 concise and front-loaded with the purpose, followed by parameter list. No extraneous content, but the structure is somewhat technical with 'Args:' labeling.

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?

Missing information about success/error responses, behavior when device not found, or safety considerations (e.g., physical movement). Output schema exists but return format isn't explained. The description is incomplete for practical 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 description adds meaning by specifying command must be one of three values (though not enforced via enum) and identifies idx/name as device identifiers. However, it lacks details on how idx and name relate, such as whether one is sufficient or both needed.

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 controls blinds or covers with specific commands (Open, Close, Stop), which is a distinct verb+resource. The name and description differentiate it from sibling tools like set_switch_state or set_dimmer_level, which target different device types.

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?

No explicit guidance on when to use vs alternatives, but the name and description imply it's for blinds only, while siblings handle switches, dimmers, etc. The context provides differentiation, but explicit usage conditions are missing.

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