Skip to main content
Glama

attach_script

Idempotent

Attach a GDScript or C# script to a scene node, replacing its existing script and saving automatically. Validate the script first to avoid instantiation errors.

Instructions

Attach a GDScript or C# script to a node in a scene, replacing any script it had. Check the script with the validate tool first. C# needs the Godot .NET build with the class compiled into the project assembly. Saves automatically. Returns: nodePath and scriptPath. Errors if the script cannot be instantiated (parse errors, @abstract, or an unbuilt C# class), or if scriptPath or nodePath does not exist. Errors while a runtime session is live on this project.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "projectPath": "<projectPath>",
      "scenePath": "<scenePath>",
      "nodePath": "<nodePath>",
      "scriptPath": "<scriptPath>"
    },
    "name": "attach_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
nodePathYesNode path from scene root (e.g. "root/Player")
scenePathYesScene file path relative to the project
scriptPathYesPath to the script file relative to the project (e.g. "scripts/player.gd" or "scripts/Player.cs"). A .cs file needs the Godot .NET build and its class compiled into the project assembly (dotnet build).
projectPathYesPath to the Godot project directory

Output Schema

NameRequiredDescriptionDefault
nodePathYesPath from the scene root in "root/..." form, read from the node.
warningsNo
scriptPathYesProject-relative path of the script that was attached.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv4.0.1
    • addedOutput schema / properties / nodePath / description
      Added value: +"Path from the scene root in \"root/...\" form, read from the node."
    • addedOutput schema / properties / scriptPath / description
      Added value: +"Project-relative path of the script that was attached."
    • removedOutput schema / properties / success
      Removed value: -{
      -  "type": "boolean"
      -}
    • addedOutput schema / properties / warnings
      Added value: +{
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / required
      Added value: +[
      +  "nodePath",
      +  "scriptPath"
      +]
  2. Changed1 schema field changedv3.8.1
    • changedInput schema / properties / scriptPath / description
      Previous value: -"Path to the GDScript file relative to the project (e.g. \"scripts/player.gd\")"New value: +"Path to the script file relative to the project (e.g. \"scripts/player.gd\" or \"scripts/Player.cs\"). A .cs file needs the Godot .NET build and its class compiled into the project assembly (dotnet build)."
  3. Addedv3.1.1
  4. Removedv3.0.0
  5. Addedv1.0.0

TDQS

A4.4/5.0
Behavior5/5

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

With only idempotentHint available, the description carries the behavioral load well: it discloses the destructive aspect (replaces the prior script), the automatic save side effect, the C# build/assembly requirement, the return fields, and three concrete failure classes (parse errors, @abstract, unbuilt C# class, missing paths, live runtime session). That is far more than the annotations convey.

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?

Purpose is front-loaded, then prerequisites, then returns, then errors — a sensible ordering with no filler. The C# .NET/assembly condition appears twice (general note and error list), a small redundancy that keeps it from a perfect score.

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?

For a 4-required-parameter mutation tool, the description covers prerequisites, side effects, return values, and the failure modes an agent must guard against. The presence of an output schema makes the return-value mention a bonus rather than a necessity, and nothing material is missing.

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 100% and each parameter already has an example-bearing description, so the baseline is 3. The description reinforces the C# compile constraint on scriptPath, but that constraint is also present in the schema, so it adds little new meaning.

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?

"Attach a GDScript or C# script to a node in a scene, replacing any script it had" gives a specific verb, the exact resource types, and the mutation scope (replacement of an existing script). An agent can distinguish this from run_script (executes) or add_node (creates) without opening a 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?

It names an explicit prerequisite workflow — "Check the script with the validate tool first" — which routes the agent to a sibling before calling. It also implies a when-not via the runtime-session error. It stops short of naming a clear alternative for the replacement case (e.g. removing a script), so it is not a full when/when-not treatment.

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