You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tools are often run without first ensuring the editor has updated the asset db and/or compiled #474
Often code is changed and the LLM will request a console read back or try to run tests, but the editor hasn't first been told to refresh the asset db and recompile. It doesn't do this automatically because it doesn't have focus. All tool calls should ensure the editor has refreshed and the calls should survive a recompile.
I am indeed talking about using an external IDE. It's not viable to have to manually pull focus on the editor every time the AI wants to do something with it - Often the AI may be spending many minutes writing code, reading from the console and fixing bugs. Having to check back manually to pull focus then allow the read_console tool is frustrating and a time sink - That kind of tool call should happen in the background without my intervention.
A good solution here would be to provide an option in the editor window settings of the package to run AssetDatabase.Refresh() on every tool call. This is assuming tool calls survive recompilations?
Yes, that's less a limitation of the mcp than the way IDEs work, but I agree it'd be nice to give the IDE a tool to reload domain when it wants to check its work. (This is how Coplay works). You would only want to call it on code changes because otherwise you don't need a recompile / domain reload.
I disagree - it's not up to the IDE to tell unity things have changed. It's a failing of the MCP tools to ensure it's operating on the latest version of the assets. It would be silly to expect every IDE to somehow know it's working with a unity project and then also somehow know how to talk to the editor right?
Also you do want to call this on all tools all the time - calling assetdatabase.refesh() won't domain reload or recompile if no code has changed. It is a harmless call to make all the time
This is one of the dangers of having an asset reload tool with our current setup. When you do an asset DB refresh, Unity reloads the MCP plugin (not something we can control) and the reconnection happens. If the LLMs don't check state, it just tries again and gets stuck in a loop. This was tried before
At least in my experience, tools and resources for testing don't work when the Unity editor isn't in focus, regardless of if I changed the state of the tests or not.
I'm not trying to discredit your problem @strich, but I think the solution is knowing how these tools work and ensuring we work with Unity in the correct way for each one.
At least from my experience with Coplay, there's a balance for users to be pulled back in focus and have LLMs do things autonomously. You won't want it to be pulled in focus on every call.
At least in my experience, tools and resources for testing don't work when the Unity editor isn't in focus, regardless of if I changed the state of the tests or not.
You may need to revalidate that - The editor should be fully capable of being run without any focus or even a head in some cases.
I understand your concerns, but outside of the Coplay env they are minor compared to the alternative where most of the tool calls are broken and don't work due to the editor working on out of date assets. It's just not fit for purpose I'm afraid.
You're completely correct though that all of this is moot as this MCP server doesn't currently survive domain reloads - That is an underlying issue that puts the breaks on everything here. You could resolve this by moving the server to an external process and implementing polling between it and the editor.
But it sounds like there is low interest in doing that work? Maybe you don't deem it important within the Coplay env (which I'm not in), which is fair enough. But it makes this MCP server unworkable for standard envs I'm afraid.
You're completely correct though that all of this is moot as this MCP server doesn't currently survive domain reloads - That is an underlying issue that puts the breaks on everything here. You could resolve this by moving the server to an external process and implementing polling between it and the editor.
But it sounds like there is low interest in doing that work? Maybe you don't deem it important within the Coplay env (which I'm not in), which is fair enough. But it makes this MCP server unworkable for standard envs I'm afraid.
This is not correct. The mcp is definitely resilient to domain reloads. If you see otherwise please submit a bug report.
I do agree it would be good to have a tool that triggers compilation / reload from IDE on demand however. Then you could let the IDE do "yolo mode" and check its own changes for compile errors,etc. Currently reloads are triggers by our script editing tools (script_apply_edit etc). But letting IDE/LLM trigger it on demand seems reasonable if it wants to.
@strich Ok check out 8.7.0. It's got a new refresh_unity tool and a bunch of smarter Unity "readiness" data that LLMs can poll to see if it's time to test, compile, etc. This should check your boxes. Thanks for the conversation and suggestions.
Activity
coderabbitai commentedon Dec 20, 2025
📝 CodeRabbit Plan Mode
Generate an implementation plan and prompts that you can use with your favorite coding agent.
Examples
🔗 Similar Issues
Possible Duplicates
Related Issues
👤 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 or schedule a call!
dsarno commentedon Dec 20, 2025
Can you offer a repro case? There are only a few tools that change code (manage_script basically). And they reload domain reliably.
If you're talking about your IDE (Claude, cursor) making changes directly, that doesn't force a reload, but Unity will reload on next focus.
strich commentedon Dec 20, 2025
I am indeed talking about using an external IDE. It's not viable to have to manually pull focus on the editor every time the AI wants to do something with it - Often the AI may be spending many minutes writing code, reading from the console and fixing bugs. Having to check back manually to pull focus then allow the read_console tool is frustrating and a time sink - That kind of tool call should happen in the background without my intervention.
A good solution here would be to provide an option in the editor window settings of the package to run
AssetDatabase.Refresh()on every tool call. This is assuming tool calls survive recompilations?dsarno commentedon Dec 20, 2025
Yes, that's less a limitation of the mcp than the way IDEs work, but I agree it'd be nice to give the IDE a tool to reload domain when it wants to check its work. (This is how Coplay works). You would only want to call it on code changes because otherwise you don't need a recompile / domain reload.
strich commentedon Dec 21, 2025
I disagree - it's not up to the IDE to tell unity things have changed. It's a failing of the MCP tools to ensure it's operating on the latest version of the assets. It would be silly to expect every IDE to somehow know it's working with a unity project and then also somehow know how to talk to the editor right?
Also you do want to call this on all tools all the time - calling assetdatabase.refesh() won't domain reload or recompile if no code has changed. It is a harmless call to make all the time
dsarno commentedon Dec 21, 2025
Can't disagree with a well stated case. Thanks for pushing back.
Don't suppose you'd like to contribute a PR for it?
strich commentedon Dec 21, 2025
The only thing I'm concerned about is whether you've made the tool calls durable over editor recompilations? I have no idea.
dsarno commentedon Dec 21, 2025
Yes tools will retry if editor is compiling, then execute when editor is ready.
See e.g.: https://github.com/CoplayDev/unity-mcp/blob/main/MCPForUnity/Editor/Services/HttpBridgeReloadHandler.cs
And
send_command_with_retryin https://github.com/CoplayDev/unity-mcp/blob/df906cb7477f9d9e4db04baa7b621284a9ba494e/Server/src/transport/legacy/unity_connection.pymsanatan commentedon Dec 22, 2025
This is one of the dangers of having an asset reload tool with our current setup. When you do an asset DB refresh, Unity reloads the MCP plugin (not something we can control) and the reconnection happens. If the LLMs don't check state, it just tries again and gets stuck in a loop. This was tried before
dsarno commentedon Dec 22, 2025
Agreed. This is too blunt a way to handle it. Most tools don't need a refresh. I'm going to try a more surgical approach.
msanatan commentedon Dec 22, 2025
At least in my experience, tools and resources for testing don't work when the Unity editor isn't in focus, regardless of if I changed the state of the tests or not.
I'm not trying to discredit your problem @strich, but I think the solution is knowing how these tools work and ensuring we work with Unity in the correct way for each one.
At least from my experience with Coplay, there's a balance for users to be pulled back in focus and have LLMs do things autonomously. You won't want it to be pulled in focus on every call.
strich commentedon Jan 1, 2026
You may need to revalidate that - The editor should be fully capable of being run without any focus or even a head in some cases.
I understand your concerns, but outside of the Coplay env they are minor compared to the alternative where most of the tool calls are broken and don't work due to the editor working on out of date assets. It's just not fit for purpose I'm afraid.
You're completely correct though that all of this is moot as this MCP server doesn't currently survive domain reloads - That is an underlying issue that puts the breaks on everything here. You could resolve this by moving the server to an external process and implementing polling between it and the editor.
But it sounds like there is low interest in doing that work? Maybe you don't deem it important within the Coplay env (which I'm not in), which is fair enough. But it makes this MCP server unworkable for standard envs I'm afraid.
dsarno commentedon Jan 1, 2026
This is not correct. The mcp is definitely resilient to domain reloads. If you see otherwise please submit a bug report.
I do agree it would be good to have a tool that triggers compilation / reload from IDE on demand however. Then you could let the IDE do "yolo mode" and check its own changes for compile errors,etc. Currently reloads are triggers by our script editing tools (script_apply_edit etc). But letting IDE/LLM trigger it on demand seems reasonable if it wants to.
dsarno commentedon Jan 3, 2026
@strich Ok check out 8.7.0. It's got a new refresh_unity tool and a bunch of smarter Unity "readiness" data that LLMs can poll to see if it's time to test, compile, etc. This should check your boxes. Thanks for the conversation and suggestions.