Skip to main content
Glama

set_asset_reference

Assigns a Unity asset (material, texture, prefab, audio clip, or ScriptGraphAsset) to an object-reference field on a scene component by path or GUID, with optional type checking and clearing.

Instructions

Assign a Unity project asset to an object-reference field on a scene component. Use this for ScriptGraphAsset, material, texture, audio clip, prefab, and other AssetDatabase references. Native serialized properties are preferred. Guarded nested CLR paths are also supported for custom serializers; use nest.macro for Unity.VisualScripting.ScriptMachine. Select the asset by Assets/... or Packages/... path, or by its 32-character Unity GUID. Set clear=true to remove the reference. Exactly one of assetPath, assetGuid, or clear=true is accepted. expectedAssetType provides an optional fail-closed type check. Requires BanterMCPBridge extension.

Input Schema

NameRequiredDescriptionDefault
clearNoSet true to clear the asset reference
objectIdNoPreferred: source GameObject globalObjectId from scene-hierarchy.json
assetGuidNoUnity asset GUID, normally returned by search_unity_assets
assetPathNoUnity asset path under Assets/ or Packages/
objectPathNoLegacy path selector for the GameObject containing the component
componentIdNoPreferred: component globalObjectId from scene-hierarchy.json
propertyNameYesObject-reference path (for example, 'material' or ScriptMachine's custom-serialized 'nest.macro')
componentTypeNoComponent type name when it is unique on the object
expectedAssetTypeNoOptional exact or assignable Unity type (for example, Unity.VisualScripting.ScriptGraphAsset)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.7.7

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses the hard prerequisite (requires BanterMCPBridge extension), the exactly-one-of assetPath/assetGuid/clear=true constraint, and that expectedAssetType is an optional fail-closed type check. It does not mention whether the scene is marked dirty, whether the change is undoable, or what a failure returns.

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 in the first sentence, followed by selector semantics, then constraints, then the environment requirement, with no filler sentences. It is dense but each line carries a distinct rule; minor cost is that 'Native serialized properties are preferred' reads as shorthand an unfamiliar agent must parse.

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 9-parameter tool with an anyOf/allOf schema and no output schema, the description covers the essential decision logic: which selector to use, how to clear, how to type-check, and the extension prerequisite. The remaining gap is return/failure behavior and the objectId-vs-objectPath precedence, both of which the schema partly documents.

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 already 100%, so the baseline is 3; the description adds real meaning on top by explaining the mutual exclusivity of assetPath, assetGuid, and clear=true, the fail-closed semantics of expectedAssetType, and the special nest.macro property path. Object selector precedence (objectId vs objectPath, componentId vs componentType) is left to the schema.

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?

The description opens with a precise verb+resource: assign a Unity project asset to an object-reference field on a scene component, and enumerates the asset kinds covered (ScriptGraphAsset, material, texture, audio clip, prefab, AssetDatabase references). It does not name or contrast with the sibling set_object_reference, so an agent must infer the asset-vs-object distinction from wording alone.

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 gives clear operating context: native serialized properties are preferred, nested CLR paths are guarded and only for custom serializers, and nest.macro is the route for Unity.VisualScripting.ScriptMachine. It also states the exclusive-selector rule and the clear=true removal path, but never says when to prefer this tool over set_object_reference or set_component_property.

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