Skip to main content
Glama

Script / Attach To Node

script-attach-to-node
DestructiveIdempotent

Attach C# or GDScript files to a Godot scene node using a node reference and res:// script path, or clear the node's script by passing an empty path.

Instructions

Attach a script (C# '.cs' or GDScript '.gd') to a Node in the currently edited Godot scene — the Godot analog of adding a MonoBehaviour to a GameObject. Identify the target with 'nodeRef' (instanceId preferred, else scene-tree path) and the script with 'scriptPath' (a res:// script file that must exist). Pass an empty/whitespace/null 'scriptPath' to DETACH (clear) the node's script. The script resource is loaded and set via Node.SetScript; the scene is marked unsaved (persist with rql-mutate 'editor | call SaveScene()'). Returns the script's structured ScriptInfo on attach, or an identity record with a 'detached' status on clear.

Argument types — give these arguments as RQL values (as in rql-mutate): {key: value, …}, [a, b], "text", 1.5, true, ref("Node3D#12") from a query result, godot.find("Name"); leave out keys you do not need: NodeRef — a node: ref("Node3D#12") from a query, godot.find("Name"), an instance id, or its path below the scene root as text ("Level/Player")

Input Schema

NameRequiredDescriptionDefault
nodeRefYesReference to the target Node (instanceId preferred, else scene-tree path). RQL: NodeRef
scriptPathNores:// path of the script to attach, ending in '.cs' or '.gd'. Pass empty/whitespace/null to DETACH the node's current script.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.35.1

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the annotations: it discloses the underlying mechanism (script resource loaded and set via Node.SetScript), the side effect that the scene is marked unsaved, the follow-up call needed to persist, and the destructive clear-on-empty behavior that explains destructiveHint=true. It also describes the return payload (structured ScriptInfo on attach, an identity record with 'detached' status on clear), which matters since there is no output schema.

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?

Dense but front-loaded: the core action, argument contract, and side effects come before the RQL value-format digression, and every sentence carries information. The only waste is the NodeRef definition appearing twice (in the 'Argument types' block and again as the trailing 'NodeRef — a node:' line).

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?

With no output schema, the description supplies the return shape for both attach and detach, and for a two-parameter mutation it covers side effects, persistence, and argument forms. Nothing an agent needs in order to call it correctly and interpret the result is missing.

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

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning: the accepted forms of nodeRef (ref("Node3D#12") from a query, godot.find("Name"), raw instance id, or scene-root-relative path) with a stated preference order. It also reinforces the extension constraint on scriptPath and the detach sentinel. The redundant restatement of NodeRef at the end of the description slightly dilutes the added value.

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?

States a specific verb+resource ('Attach a script ... to a Node') and bounds the scope to 'the currently edited Godot scene'. It further disambiguates from siblings by explaining the tool also performs DETACH when scriptPath is empty, and grounds the concept with 'the Godot analog of adding a MonoBehaviour to a GameObject'. An agent can distinguish this from script-create/script-update/script-delete without opening any schema.

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?

Gives clear operating context: attach in the currently edited scene, scriptPath must point to an existing res:// file, and persisting requires a separate rql-mutate 'editor | call SaveScene()'. It also defines the detach path and its precondition. It stops short of explicitly saying 'use script-create first if the file does not exist' or naming script-update as the alternative for changing script contents, so alternatives are only implied.

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