Skip to main content
Glama

attach_script

Idempotent

Attaches a GDScript or C# script to a node in a Godot scene, replacing any previous script and saving automatically. Use after validating the script to ensure it can be instantiated.

Instructions

Attach a GDScript or C# script to a node in a scene. Use after writing and validating it via the validate tool. C# needs the Godot .NET build with the class compiled into the project assembly. Replaces any previous script. Saves automatically. Returns: success with nodePath and scriptPath. Errors if the script can't be instantiated (parse errors, @abstract, or an unbuilt C# class), scriptPath doesn't exist, or nodePath isn't found. Errors while a Godot runtime session is active; stop_project (or detach_project) clears it.

Input Schema

TableJSON 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

TableJSON Schema
NameRequiredDescriptionDefault
successNo
nodePathNo
scriptPathNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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)."
  2. Addedv3.1.1
  3. Removedv3.0.0
  4. Addedv1.0.0

TDQS

A4.5/5.0
Behavior5/5

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

Beyond the idempotentHint annotation, the description discloses that the tool 'Replaces any previous script,' 'Saves automatically,' returns a specific success payload, and enumerates error conditions including parse errors, unbuilt C# classes, missing paths, and active runtime sessions. This is far more behavioral detail than the annotation alone provides.

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 tightly written with no filler, leading with the primary action and then layering usage, behavior, return value, and error cases in a logical order. Every sentence adds operational value.

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 mutation tool with 4 required parameters, full schema coverage, and an output schema, the description covers success format, error conditions, persistence behavior, and runtime interactions. An agent has enough information to invoke the tool correctly and anticipate failures.

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?

The input schema has 100% coverage and already describes each parameter, including the .cs/.gd distinction and relative path examples. The description adds relevant behavioral context but does not meaningfully improve understanding of individual parameter semantics beyond the schema.

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 ('Attach'), a clear resource ('a GDScript or C# script to a node in a scene'), and immediately distinguishes itself from script execution workflows. The description clearly identifies what the tool does and what it takes, leaving little ambiguity.

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?

Explicitly says to use the tool 'after writing and validating it via the validate tool,' which gives important sequencing context. It also explains the C# .NET build requirement and the runtime-session restriction, but it does not explicitly contrast with sibling tools like run_script or add_node.

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