-
Notifications
You must be signed in to change notification settings - Fork 585
Description
Environment
Unity MCP Version: 8.3.0
Connection Type: HTTP
Description
I am experiencing an issue where custom tools fail to trigger correctly, whereas the built-in official commands work perfectly fine.
When attempting to use a custom tool, the system persistently throws an error indicating that unity_instances cannot be found. The LLM fails to list the unity_instances or automatically call set_active_instance to select the context.
Root Cause Analysis
It seems that the _inject_unity_instance logic does not automatically resolve the target instance for custom tools, even when there is only one active connection.
Proposed Solution / Workaround
I managed to fix this issue by modifying the server source code, specifically within the _inject_unity_instance section.
The Logic Change: I added a check for the number of active Unity instances:
If there is exactly one Unity instance connected: The system should automatically select and inject this instance.
If there are zero or multiple instances: Keep the original behavior (throw an error or require manual selection).
After implementing this logic, my custom tools are triggering correctly. I suggest merging a similar logic into the official release to improve the developer experience for single-instance setups.
Note: This issue description was translated and summarized by AI.