Error with server port conflict
Love the work and the update. Here is a issue I found with the MCP Bridge thing, it keeps giving me this error when Start Bridge is clicked:
I suppose the hardcoded unityPort should be changed to 6400? The error was resolved after I edited it from 6500 to 6400.
You likely already have another instance of Unity with Unity MCP open. Right now it doesn't support multiple projects at the same time since there's no way to know which Unity project your client should interact with
A bunch of caches left over in the PackageCache folder made these mistakes. Good after cleaned up. Thanks!
Did you find a solution for Error:Port 6400 is already in use. Ensure no other instances are running or change the port.
Did you find a solution for Error:Port 6400 is already in use. Ensure no other instances are running or change the port.
I think I am encountering a similar issue as I am currently writing a bidirectional communication toolkit. Last time my solution was to use something that can check your local port number, delete whatever is using 6400, and that problem is fixed.
I also thought trying deleting the port to empty it. Problem is that when I delete the port, it also exits the unity automatically. And when I open unity again, the process starts all over again.
Right now, when you open unity, it automatically connects to port 6400 without even entering play mode, however when you enter play mode, it tries again to connect to port 6400 and gets the error: It's been used. So the solution should be to assign different port numbers each tie you enter play mode in my opinion. But I haven't tested out yet
Do you open multiple projects or just one (or have multiple projects using Unity-MCP and its not cleaned up)? The way it connects port 6400 is at the start() function in McpBridge.cs, where a TcpListener is opened and listening to incoming IDE commands, and it initializes on load (start of Unity essentially), which means it should not matter if you enter the play mode or stay in the editor mode. I think if your problem is that it works fine in Editor mode but not in Play mode, tweak the [InitialzeOnLoad] tag may be a quick fix. Yeah I agree it is a prototype feature and the port is basically hardcoded, figuring out how to assign multiple ports efficiently through multiple programs might be a interesting engineering problem.
I tried to change the port number to 6401 in the following scripts, and it worked: config.py ; UnityMcpEditorWindow.cs ; UnityMcpBridge.cs However after I close the unity project and open it back up, this time it gives the same error only for port 6401. This was just a manual quick fix. There must be auto increment of the port number in all these 3 scripts each time you restart to unity project. But for now this quick fix should work