Summary
Running two Unity projects with the plugin at the same time (each on its own port) results in mutual exclusion: connecting/recompiling one Editor drops the other's MCP connection. Reconnect that one and the first drops. Only one project stays connected at a time, even though their ports differ.
Environment
- Plugin:
com.ivanmurzak.unity.mcp 0.81.0 (also present on main)
- OS: Windows 11; two separate Unity projects, ports 26645 and 26646
connectionMode: Custom, keepServerRunning: true
Repro
- Open project A (port 26645) -> its server starts, MCP connects.
- Open project B (port 26646) -> its server starts, MCP connects.
- Recompile / enter Play / reconnect in project A -> project B's MCP connection drops (connection-refused on B's port; B's
gamedev-mcp-server is gone).
- Symmetric: touching B second kills A.
Root cause
McpServerManager stores the running server PID under a fixed EditorPrefs key, "McpServerManager_ProcessId", that is not qualified by port/project. EditorPrefs are machine-global (shared across all projects of the same Editor version), so both Editors read/write one slot. After B overwrites the slot with B's PID, A's CheckExistingProcess() (on domain reload) reads B's PID, adopts B's server as its own _serverProcess, and StopServer() later terminates it. The per-project binary folder (Library/mcp-server) and KillOrphanedServerProcesses() are already port-scoped -- this PID key is the last piece of shared state.
Fix
Qualify the key by port. PR opened against this issue.
Summary
Running two Unity projects with the plugin at the same time (each on its own port) results in mutual exclusion: connecting/recompiling one Editor drops the other's MCP connection. Reconnect that one and the first drops. Only one project stays connected at a time, even though their ports differ.
Environment
com.ivanmurzak.unity.mcp0.81.0 (also present onmain)connectionMode: Custom,keepServerRunning: trueRepro
gamedev-mcp-serveris gone).Root cause
McpServerManagerstores the running server PID under a fixedEditorPrefskey,"McpServerManager_ProcessId", that is not qualified by port/project.EditorPrefsare machine-global (shared across all projects of the same Editor version), so both Editors read/write one slot. After B overwrites the slot with B's PID, A'sCheckExistingProcess()(on domain reload) reads B's PID, adopts B's server as its own_serverProcess, andStopServer()later terminates it. The per-project binary folder (Library/mcp-server) andKillOrphanedServerProcesses()are already port-scoped -- this PID key is the last piece of shared state.Fix
Qualify the key by port. PR opened against this issue.