-
Notifications
You must be signed in to change notification settings - Fork 694
Description
Version: MCP for Unity 9.2.0 (com.coplaydev.unity-mcp)
Unity Version: 6000.0.31f1 (Unity 6)
OS: Windows
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
BUG #1: AudioSource Reference Conversion Failure
Tool Call:
{
"tool": "manage_components",
"action": "set_property",
"target": "AudioManager",
"component_type": "AudioManager",
"property": "musicSource",
"value": 12345
}
Note: Passing integer where AudioSource object reference expected
Error in Editor.log (Line 7870):
[UnityEngineObjectConverter] Unexpected token type 'Integer' when deserializing AudioSource. Expected Null, String, or Object.
MCP-FOR-UNITY: [ManageComponents] Failed to convert value for field 'musicSource' to type 'AudioSource'.
Stack:
MCPForUnity.Editor.Helpers.PropertyConversion:ConvertToType
MCPForUnity.Editor.Helpers.ComponentOps:SetProperty
MCPForUnity.Editor.Tools.ManageComponents:TrySetProperty
MCPForUnity.Editor.Tools.ManageComponents:SetProperty
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
BUG #2: Vector2 Array Format Rejection
Tool Call:
{
"tool": "manage_components",
"action": "set_property",
"target": "RaceResultsPanel",
"component_type": "RectTransform",
"property": "anchorMin",
"value": [0, 0]
}
Error in Editor.log (Line 16044):
MCP-FOR-UNITY: Error converting token to UnityEngine.Vector2: Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path 'value'.
Token: [0,0]
MCP-FOR-UNITY: [ManageComponents] Failed to set property 'anchorMin'
Stack:
MCPForUnity.Editor.Helpers.PropertyConversion:ConvertToType
MCPForUnity.Editor.Helpers.ComponentOps:SetProperty
MCPForUnity.Editor.Tools.ManageComponents:TrySetProperty
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CRITICAL ISSUE: Command Dispatcher Crash
After PropertyConversion exceptions:
✅ telemetry_ping continues working
✅ telemetry_status returns success
❌ All other tools fail: "No Unity Editor instances found"
❌ Instance registry corrupted
Reproduction:
- Call manage_components with set_property
- Pass incompatible type (int for Object, array for Vector2)
- PropertyConversion throws unhandled exception
- Subsequent commands fail silently
- telemetry_ping still succeeds → false positive
Workaround: Restart MCP window
// SUGGESTED FIX #1: Graceful Error Handling
public static object ConvertToType(JToken token, Type targetType)
{
try
{
return ConvertLogic(token, targetType);
}
catch (Exception ex)
{
McpLog.Error($"Convert failed: {ex.Message}");
return null; // Don't crash dispatcher
}
}
// SUGGESTED FIX #2: Support Multiple Vector2 Formats
if (targetType == typeof(Vector2))
{
if (token.Type == JTokenType.Array)
{
var arr = token.ToObject<float[]>();
return new Vector2(arr[0], arr[1]);
}
else if (token.Type == JTokenType.Object)
{
return token.ToObject<Vector2>();
}
}
// SUGGESTED FIX #3: UnityEngine.Object Instance ID Support
if (typeof(UnityEngine.Object).IsAssignableFrom(targetType))
{
if (token.Type == JTokenType.Integer)
{
int instanceId = token.ToObject<int>();
return EditorUtility.InstanceIDToObject(instanceId);
}
}
// SUGGESTED FIX #4: Telemetry Should Reflect State
public class TelemetryStatus
{
public bool Connected { get; set; }
public bool CommandDispatcherHealthy { get; set; } // NEW
public string LastError { get; set; } // NEW
}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IMPACT
Severity: HIGH
- Silent failures mislead users/AI agents
- Unrecoverable without restart
- No error visibility in telemetry
- Breaks workflows relying on status checks
Frequency: Common when setting properties programmatically
Affected: manage_components, all tools using PropertyConversion
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ADDITIONAL CONTEXT
MCP Successfully Restarted 3 Times:
Line 45974: StdioBridgeHost started on port 6400
Line 46063: StdioBridgeHost started on port 6400
Line 46102: StdioBridgeHost started on port 6400
→ Shows recovery is possible, but requires manual intervention
Connection Was Stable Before PropertyConversion Errors:
- Tool calls worked fine initially
- Errors only occurred during component property setting
- Previous manage_gameobject, manage_scene calls succeeded
Similar Issues Likely Affect:
- Vector3 (position, rotation, scale)
- Vector4 (colors, shader properties)
- Color (material colors)
- Quaternion (rotations)
→ Any Unity struct using array format will fail
AI Agent Context:
- This bug specifically impacts AI agents (Claude, etc)
- Agents naturally use array format: [x,y,z] not {x:x, y:y, z:z}
- No documentation on MCP API shows correct format
- Tool parameter descriptions don't specify object vs array
Documentation Gap:
Current manage_components docs don't show:
- How to reference UnityEngine.Object types (instance ID? GUID? path?)
- Expected format for Vector2/3/4 (array or object?)
- Which properties support programmatic setting
- Error recovery when conversion fails
False Positive in Tool Description:
manage_components tool says it can "set_property" but:
- Fails on common Unity types
- No validation before attempting
- No graceful degradation
- Misleading success on telemetry while dispatcher dead