Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

search_scripts

Search across Domoticz event scripts (Lua, dzVents, Python) for a given string to find relevant code sections.

Instructions

Search for a specific string inside event scripts (Lua, dzVents, Python, etc.).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `search_scripts` async function is the handler for the tool. It fetches the list of event scripts via Domoticz API, loads each script's source code, and searches case-insensitively for the query string within the script source. Returns matching scripts with name, interpreter, type, and status.
    @mcp.tool()
    async def search_scripts(query: str) -> str:
        """Search for a specific string inside event scripts (Lua, dzVents, Python, etc.)."""
        async with create_client() as client:
            # 1. Get the list of scripts
            list_resp = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=events&evparam=list")
            scripts = list_resp.json().get("result", [])
            
            matches = []
            query_lower = query.lower()
            
            # 2. For each script, load its source and search
            for script in scripts:
                script_id = script.get("idx")
                load_resp = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=events&evparam=load&event={script_id}")
                script_data = load_resp.json().get("result", [{}])[0]
                
                source_code = script_data.get("xml", "") or script_data.get("source", "")
                if query_lower in source_code.lower():
                    matches.append({
                        "idx": script_id,
                        "Name": script.get("name"),
                        "Interpreter": script.get("interpreter"),
                        "Type": script.get("eventtype"),
                        "Status": "Enabled" if script.get("eventstatus") == "1" else "Disabled"
                    })
                    
            return json.dumps({"status": "OK", "result": matches, "count": len(scripts)})
  • The `@mcp.tool()` decorator on the `search_scripts` function registers it as a tool with the FastMCP server, making it available via the MCP protocol.
    @mcp.tool()
  • The `_format_response` helper is used by many tool handlers (though search_scripts uses json.dumps directly) to format dicts as JSON strings.
    def _format_response(data: Dict[str, Any]) -> str:
        """Format a dictionary as a JSON string response."""
        return json.dumps(data)
  • The `create_client` helper function is used by search_scripts to create an HTTP client for Domoticz API calls.
    def create_client(own_client: bool = False) -> DomoticzClient:
        """Create a DomoticzClient instance.
    
        Args:
            own_client: If True, creates a dedicated client that will be closed on exit.
                        If False (default), uses a shared client for connection pooling.
        """
        return DomoticzClient(own_client=own_client)
Behavior2/5

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

No annotations are provided, so the description bears full responsibility for behavioral disclosure. It only states 'search for a specific string' without explaining case sensitivity, match type (e.g., exact, substring, regex), or return behavior.

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, concise sentence that conveys the core purpose without unnecessary words or repetition.

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 tool's simplicity (one required parameter) and the presence of an output schema, the description captures the essential function. However, the lack of usage guidance and behavioral details prevents it from being fully complete for an effective agent.

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 input schema has one required parameter 'query' with no description, and schema description coverage is 0%. The description does not elaborate on what 'query' accepts (e.g., format, special characters), forcing the agent to guess.

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 verb 'Search', the resource 'event scripts', and the action 'for a specific string'. It lists example script types (Lua, dzVents, Python, etc.), making it distinct from sibling tools like search_devices.

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 does it specify any preconditions or exclusions. The agent is left to infer usage context.

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