Skip to main content
Glama
adrighem

Domoticz MCP Server

by adrighem

search_scripts

Search event scripts for a specific string to find code across Lua, dzVents, Python, and other languages.

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 actual implementation of the search_scripts tool handler. It fetches the list of event scripts from Domoticz, then for each script loads its source code and searches for the query string (case-insensitive). Returns matching scripts with their idx, 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 tool is registered via the @mcp.tool() decorator on the search_scripts async function, using the FastMCP instance 'mcp' created on line 70.
    @mcp.tool()
    async def search_scripts(query: str) -> str:
  • The _format_response helper used indirectly via json.dumps calls within search_scripts to format the JSON response.
    def _format_response(data: Dict[str, Any]) -> str:
        """Format a dictionary as a JSON string response."""
        return json.dumps(data)
  • The _error_response helper is a supporting utility for error formatting (not directly called by search_scripts but available in the same module).
    def _error_response(message: str, status: str = "error") -> str:
        """Format an error response as a JSON string."""
        return json.dumps({"status": status, "message": message})
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It does not disclose behavioral traits such as whether it returns file paths, line numbers, context, or if it supports regex. Lacks critical behavioral details for an agent.

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, concise but lacking structure. It is minimally viable but could be expanded slightly to include additional context without sacrificing conciseness.

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 tool has one parameter and an output schema, the description is too sparse. It omits important details like what is included in the results and any constraints, making it incomplete for full understanding.

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?

With schema description coverage at 0%, the description should compensate but only states 'search for a specific string', adding no extra meaning about the 'query' parameter format, case sensitivity, or special syntax. The baseline for low coverage is not met.

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 that the tool searches for a specific string inside event scripts (Lua, dzVents, Python, etc.), providing a specific verb and resource. It is well differentiated from sibling tool 'search_devices' which searches 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?

No guidance on when to use this tool versus alternatives like 'search_devices' or other context. No when-not-to-use or preconditions are mentioned, leaving the agent without clear direction.

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