Skip to main content
Glama

Attach Script to GameObject

unity_attach_script

Attach a MonoBehaviour script to a GameObject in Unity Editor with undo support. Requires compiled script; fails with a hint if class is missing.

Instructions

Attach a MonoBehaviour class to a GameObject (Undo-able). Script must be compiled — no compile errors in console.

Args: object_path ('Player'), script_class ('PlayerController'). Fails with hint if the class is not found (typo? not compiled yet?) — read the error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
object_pathYesHierarchy path of the GameObject, e.g. 'Player'
script_classYesMonoBehaviour class name to attach, e.g. 'PlayerController'

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare the safety profile (readOnly=false, destructive=false, idempotent=false), so the description isn't carrying that burden. It adds genuine behavioral detail beyond the annotations: the operation is Undo-able, it requires prior compilation, and it fails with a hint on class-not-found. It doesn't cover what happens if the class already exists on the object.

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?

Extremely tight: one sentence for purpose, one for the precondition, one line of args, one line for the failure mode. The core action is front-loaded and every sentence earns its place.

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

Completeness4/5

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

For a 2-param mutation with no output schema, the description covers purpose, precondition, and failure behavior, which is close to complete. The main remaining gap is the lack of a stated distinction from unity_add_component.

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%, so both parameters are already documented in the schema, including the same 'Player'/'PlayerController' examples. The description adds nothing beyond that baseline, so a 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: 'Attach a MonoBehaviour class to a GameObject'. An agent immediately knows this attaches a script component to an existing object. It does not explicitly differentiate itself from the sibling unity_add_component, which is the nearest ambiguous neighbor.

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

Usage Guidelines3/5

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

Gives a real precondition ('Script must be compiled — no compile errors in console') and a failure path, which is useful context. However, it never states when to prefer this over unity_add_component or what to do if the GameObject path is invalid, so the when-to-use guidance is only implied.

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