Skip to main content
Glama
tim661811
by tim661811

Replace the code of a HomeyScript script

homey_script_update

Replace an existing Homey script's code by id or exact name, and get the previous code back to undo changes if needed.

Instructions

Replaces the code of a script that already exists, found by id or exact name. The previous code is returned so the change can be undone from the result alone. Write scripts to be reusable. Take what varies as an argument rather than baking it in: the HomeyScript Flow card passes text into the script as args[0], so one script can serve several Flows and several rooms. Prefer looking a device up by what it IS over what its id is, for example by zone and capability, so the script survives a device being replaced. Prefer returning a value and letting the Flow act on it over acting inside the script. A script that answers "should I open the window" can be reused; one that also opens the window cannot. A hard-coded device id is acceptable when there is genuinely no other way, or when a lookup would be more fragile than the id. It is the exception, and it is worth a comment saying why. This server cannot see log() output: it goes to the HomeyScript app console and no route here reads it. What comes back is the return value, so return whatever needs checking rather than logging it. While a script is being written, return an object with the intermediate values in it; trim it to the real answer once it works.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe JavaScript that replaces what is there now.
scriptYesThe script id, or its exact name.
Install Server

TDQS

A4.3/5.0
Behavior5/5

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

Beyond annotations, the description discloses two critical behaviors: (1) the previous code is returned to allow undo, and (2) log() output is not visible to this server; only the return value is observed. These details are not available in annotations or schema, significantly enhancing transparency for agent decision-making and debugging.

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 long, extending well into script authoring best practices. While all sentences offer value, the length dilutes the tool's core mechanics. It is not concise; however, it is structurally front-loaded with the purpose sentence, and the guidance is organized logically. A more compact version could retain key points.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema, the description fully covers the return value (previous code) and the log limitation. It also provides extensive context on script design principles, making it complete for an agent to use the tool effectively. There are no major gaps in behavioral expectations or usage context.

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 description coverage is 100%, with both parameters (script and code) already described. The description adds context about the script parameter (id or exact name) but this duplicates the schema. While the extensive guidance on script writing informs the code content, it does not directly enrich parameter semantics beyond what the schema provides. Baseline 3 applies.

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 opens with a specific statement: 'Replaces the code of a script that already exists, found by id or exact name.' This clearly identifies the verb (replace), resource (code of an existing script), and the lookup method (id or exact name). It is immediately distinct from creation, deletion, or running, as seen in sibling tools.

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

Usage Guidelines4/5

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

The description implies usage for existing scripts by stating 'that already exists' and specifying lookup by id or exact name. However, it does not explicitly contrast with create or run tools, nor does it state when not to use it. The context makes the primary use case clear, but exclusions are omitted.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/tim661811/homey-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server