Domain reload and "state unknown" errors
When Unity compiles or enters Play Mode it reloads all scripts (a domain reload). The server is part of the Editor, so it stops for a few seconds.
A request cut off by a reload gets a JSON-RPC error that says so. The tool may already have finished. So:
- Wait until
/healthanswers again (it also answers during compilation). - Read the state —
mcp_status, theunity://editor/stateresource, or thestatusaction ofmanage_playmode. - Only then decide whether to repeat the change. Do not repeat a change blindly; it may already have happened.
Avoid the reload on Play
Section titled “Avoid the reload on Play”In Project Settings > Editor > Enter Play Mode Settings, untick Reload Domain. Entering Play Mode then no longer restarts the server. Your own scripts must then cope with static fields that are not reset.