Repository navigation
Closed
Description
The Editor crashes randomly when mcp tools are being called (probably they have incorrect values or something). I am using Claude Code but had the same issues earlier with Windsurf/Antigravity
The mcp server shows no errors
2025-12-27 12:20:11,999 - mcp.server.streamable_http_manager - INFO - Created new transport with session ID: 3af34d3cc794418c8e14fbe8673567fd
INFO: ::1:60878 - "POST /mcp HTTP/1.1" 200 OK
INFO: ::1:60878 - "POST /mcp HTTP/1.1" 202 Accepted
INFO: ::1:60878 - "GET /mcp HTTP/1.1" 200 OK
INFO: ::1:60908 - "POST /mcp HTTP/1.1" 200 OK
INFO: ::1:60910 - "POST /mcp HTTP/1.1" 200 OK
INFO: ::1:60913 - "POST /mcp HTTP/1.1" 200 OK
2025-12-27 12:20:35,928 - mcp.server.streamable_http_manager - INFO - Created new transport with session ID: 9677297299d446cfaf42755df5784d0e
INFO: ::1:61001 - "POST /mcp HTTP/1.1" 200 OK
INFO: ::1:61001 - "POST /mcp HTTP/1.1" 202 Accepted
INFO: ::1:61001 - "GET /mcp HTTP/1.1" 200 OK
INFO: ('::1', 61019) - "WebSocket /hub/plugin" [accepted]
INFO: connection open
INFO: ::1:61261 - "POST /mcp HTTP/1.1" 200 OK
INFO: ::1:61261 - "POST /mcp HTTP/1.1" 200 OK
INFO: ::1:61307 - "POST /mcp HTTP/1.1" 200 OK
INFO: ::1:61348 - "POST /mcp HTTP/1.1" 200 OK
INFO: ::1:61381 - "POST /mcp HTTP/1.1" 200 OK
INFO: ::1:61381 - "POST /mcp HTTP/1.1" 200 OK
Claude code shows MCP response with "Python error managing GameObject: " with no meaningful error message
⎿ {
"success": true,
"message": "Found 1 GameObject(s).",
… +63 lines (ctrl+o to expand)
⏺ UnityMCP - manage_scene (MCP)(action: "get_hierarchy")
⎿ {
"success": true,
"message": "Retrieved hierarchy for scene 'SampleScene'.",
… +3696 lines (ctrl+o to expand)
⏺ I can see the player has a child model HumanMale_Character_FREE. Let me check its Animator component:
⏺ UnityMCP - manage_gameobject (MCP)(action: "get_component", target: "HumanMale_Character_FREE", component_name: "Animator")
⎿ {
"success": false,
"message": "Python error managing GameObject: "
}
⏺ UnityMCP - manage_gameobject (MCP)(action: "get_components", target: "HumanMale_Character_FREE")
⎿ {
"success": false,
"message": "Python error managing GameObject: No Unity plugins are currently connected"
}
⏺ Unity connection dropped. Let me check your existing PlayerAnimator controller to see what parameters it has:
Reacted by coderabbitai
Metadata
Metadata
Assignees
Labels
No labels
Activity
coderabbitai commentedon Dec 27, 2025
📝 CodeRabbit Plan Mode
Generate an implementation plan and prompts that you can use with your favorite coding agent.
✅ Successfully generated implementation plan.
💡 Use
@coderabbitai <feedback>to replanExamples
🔗 Similar Issues
Possible Duplicates
Related Issues
🔗 Related PRs
#266 - Fix: Unity Editor reload crash + debug-noise reduction [merged]
👤 Suggested Assignees
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
coderabbitai commentedon Dec 28, 2025
Coding Plan
Approach
Ticket Summary
Unity Editor crashes when MCP tools attempt to serialize Animator components via reflection. The crash occurs without meaningful error messages, and the Python server only returns empty error strings like "Python error managing GameObject: ". The root cause is that Animator component properties are unsafe to access via reflection during serialization, causing Unity's engine to crash.
Observations
Codebase Summary
This is a Unity MCP (Model Context Protocol) integration with a Python server and Unity C# client that communicate via WebSocket. The Python server (
Server/src/) implements MCP tools for GameObject manipulation, while the Unity client (MCPForUnity/Editor/) handles command execution and serializes component data using reflection. The serialization system has special handling for crash-prone components like Transform and Camera, but lacks protection for Animator. Error handling follows a consistent pattern across both layers, with try-catch blocks converting exceptions to structured JSON responses.Assumptions
Assumption 1: How much Animator data should users be able to access?
Options Considered:
Chosen Option: Skip Animator entirely
Rationale: This is the simplest solution that follows Unity best practices (web search confirms Animator properties accessing engine-managed data should not be called during serialization), eliminates all crash risk, and aligns with the existing component filtering pattern. Users can still check if Animator exists on a GameObject; they just won't see its internal property values. If users need basic Animator data in the future, we can add a curated safe-list as a follow-up enhancement.
💡 User Tips
Regenerate the plan with different choices with
@coderabbitai <feedback>.Implementation Steps
Phase 1: Prevent Unity Crashes by Filtering Animator Components
This phase modifies the Unity serialization layer to skip Animator components entirely, preventing the reflection-based property access that causes crashes. This is the critical fix that directly resolves the crash issue.
Task 1: Add Animator to Component Type Blacklist
Update the component serialization logic to explicitly skip Animator components before attempting property reflection.
MCPForUnity/Editor/Helpers/GameObjectSerializer.csin theGetComponentData()method to add a check for Animator component type before the existing Transform/Camera special casescomponent is Animatororcomponent.GetType() == typeof(Animator))Task 2: Handle Animator in Component Iteration
Ensure the component iteration logic properly handles Animator components when collecting all components from a GameObject.
MCPForUnity/Editor/Services/ManageGameObject.csin theGetComponentsFromTarget()method to check component type before callingGameObjectSerializer.GetComponentData()🤖 Prompt for AI agents
Phase 2: Improve Error Diagnostics in Python Server
This phase enhances error handling to provide meaningful error messages when problems occur, addressing the empty error string issue. While this doesn't prevent crashes, it significantly improves debuggability for all error scenarios.
Task 1: Preserve Full Exception Information in Tool Error Handling
Update exception handling in MCP tool implementations to capture and log full tracebacks before returning error responses.
Server/src/services/tools/manage_gameobject.pyexception handler (lines 239-240) to log the full exception with traceback usinglogger.exception()orlogger.error(..., exc_info=True)before constructing the error responsestr(e)and the exception type (e.g.,f"Python error managing GameObject: {type(e).__name__}: {e!s}")manage_editor.py,manage_shader.py,manage_scene.py,manage_script.py,manage_prefabs.py)Task 2: Enhance WebSocket Error Reporting
Improve error propagation through the WebSocket communication layer to ensure Unity crashes and connection drops are properly detected and reported.
Server/src/transport/plugin_hub.pyin theon_disconnect()and command execution handlers to ensure disconnections during command execution result in clear timeout errors rather than empty messagesasyncio.wait_for()wrapper include the command_id and action being performed🤖 Prompt for AI agents
Phase 3: Documentation and Future Enhancements
This phase documents the changes and provides guidance for future improvements if users need more Animator data.
Task 1: Document Animator Serialization Limitation
Add code comments and potentially user-facing documentation explaining why Animator is skipped.
GameObjectSerializer.csexplaining the Animator exclusion and referencing Unity's serialization restrictionsget_componentandget_componentsactionsTask 2: Create Path for Future Safe Animator Properties
Set up the structure to allow adding safe Animator properties in the future if needed.
enabled,speed,cullingMode) versus unsafe (e.g.,runtimeAnimatorController,avatar, layer/parameter queries)🤖 Prompt for AI agents
🚀 Next Steps
🤖 All AI agent prompts combined
💡 Iterate on the plan with:
@coderabbitai <feedback>💬 Have feedback or questions? Drop into our discord!
dsarno commentedon Dec 28, 2025
Hi @ValiDraganescu -- thanks for the report. I've hard a hard time reproducing the crash you're talking about in Unity 6.3 on Windows, getting component / gameobject data about animators or large hierarchies. If you're able to give more detail on the unity scene you're getting the crashes with -- how many objects in the hierarchy. And how many components, with how much serialized data, on the
HumanMale_Character_FREE.It doesn't seem to be a global problem with the Unity MCP and Unity 6.3, or even with the get_components or get_hierarchy actions -- although both of those definitely need to be refactored to handle large payloads. They were written early in the history of the unity_mcp and not optimized. (Referenced in #455 -- probably the same issue).
dsarno commentedon Dec 29, 2025
Should be fixed in latest release
8.4.0. Please let us know if you continue seeing this type of issue.