File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
MCPForUnity/Editor/Services/Transport/Transports Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -682,16 +682,18 @@ private static Uri BuildWebSocketUri(string baseUrl)
682682 throw new InvalidOperationException ( $ "Invalid MCP base URL: { baseUrl } ") ;
683683 }
684684
685- string scheme = httpUri . Scheme . Equals ( "https" , StringComparison . OrdinalIgnoreCase ) ? "wss" : "ws" ;
686- string builder = $ "{ scheme } ://{ httpUri . Authority } ";
687- if ( ! string . IsNullOrEmpty ( httpUri . AbsolutePath ) && httpUri . AbsolutePath != "/" )
688- {
689- builder += httpUri . AbsolutePath . TrimEnd ( '/' ) ;
690- }
685+ // Replace 0.0.0.0 with localhost for client connections
686+ // 0.0.0.0 is only valid for server binding, not client connections
687+ string host = httpUri . Host == "0.0.0.0" ? "localhost" : httpUri . Host ;
691688
692- builder += "/hub/plugin" ;
689+ var builder = new UriBuilder ( httpUri )
690+ {
691+ Scheme = httpUri . Scheme . Equals ( "https" , StringComparison . OrdinalIgnoreCase ) ? "wss" : "ws" ,
692+ Host = host ,
693+ Path = ( httpUri . AbsolutePath . TrimEnd ( '/' ) + "/hub/plugin" ) . TrimStart ( '/' )
694+ } ;
693695
694- return new Uri ( builder ) ;
696+ return builder . Uri ;
695697 }
696698 }
697699}
You can’t perform that action at this time.
0 commit comments