diff --git a/MCPForUnity/Editor/Services/Transport/Transports/WebSocketTransportClient.cs b/MCPForUnity/Editor/Services/Transport/Transports/WebSocketTransportClient.cs index 4588e4a60..65b4e4873 100644 --- a/MCPForUnity/Editor/Services/Transport/Transports/WebSocketTransportClient.cs +++ b/MCPForUnity/Editor/Services/Transport/Transports/WebSocketTransportClient.cs @@ -682,9 +682,14 @@ private static Uri BuildWebSocketUri(string baseUrl) throw new InvalidOperationException($"Invalid MCP base URL: {baseUrl}"); } - // Replace 0.0.0.0 with localhost for client connections - // 0.0.0.0 is only valid for server binding, not client connections - string host = httpUri.Host == "0.0.0.0" ? "localhost" : httpUri.Host; + // Replace bind-only addresses with localhost for client connections + // 0.0.0.0 and :: are only valid for server binding, not client connections + string host = httpUri.Host; + if (host == "0.0.0.0" || host == "::") + { + McpLog.Warn($"[WebSocket] Base URL host '{host}' is bind-only; using 'localhost' for client connection."); + host = "localhost"; + } var builder = new UriBuilder(httpUri) { diff --git a/MCPForUnity/Editor/Windows/Components/Common.uss b/MCPForUnity/Editor/Windows/Components/Common.uss index 5aa6e988c..fdaa7001f 100644 --- a/MCPForUnity/Editor/Windows/Components/Common.uss +++ b/MCPForUnity/Editor/Windows/Components/Common.uss @@ -437,7 +437,7 @@ margin-bottom: 4px; } -.help-text.error { +.help-text.http-local-url-error { color: rgba(255, 80, 80, 1); -unity-font-style: bold; } diff --git a/MCPForUnity/Editor/Windows/Components/Connection/McpConnectionSection.cs b/MCPForUnity/Editor/Windows/Components/Connection/McpConnectionSection.cs index 782ed7b9f..f54dcb8f6 100644 --- a/MCPForUnity/Editor/Windows/Components/Connection/McpConnectionSection.cs +++ b/MCPForUnity/Editor/Windows/Components/Connection/McpConnectionSection.cs @@ -420,6 +420,7 @@ public void UpdateHttpServerCommandDisplay() httpServerCommandSection.style.display = DisplayStyle.None; httpServerCommandField.value = string.Empty; httpServerCommandField.tooltip = string.Empty; + httpServerCommandField.SetEnabled(false); if (httpServerCommandHint != null) { httpServerCommandHint.text = string.Empty; @@ -435,22 +436,24 @@ public void UpdateHttpServerCommandDisplay() if (!isLocalHttpUrl) { - httpServerCommandField.value = ""; - httpServerCommandField.tooltip = "The command cannot be generated because the URL is not a local address."; - httpServerCommandSection.EnableInClassList("invalid-url", true); + httpServerCommandField.value = string.Empty; + httpServerCommandField.tooltip = string.Empty; + httpServerCommandField.SetEnabled(false); + httpServerCommandSection.EnableInClassList("http-local-invalid-url", true); if (httpServerCommandHint != null) { httpServerCommandHint.text = "⚠ HTTP Local requires a localhost URL (localhost/127.0.0.1/0.0.0.0/::1)."; - httpServerCommandHint.AddToClassList("error"); + httpServerCommandHint.AddToClassList("http-local-url-error"); } copyHttpServerCommandButton?.SetEnabled(false); return; } - httpServerCommandSection.EnableInClassList("invalid-url", false); + httpServerCommandSection.EnableInClassList("http-local-invalid-url", false); + httpServerCommandField.SetEnabled(true); if (httpServerCommandHint != null) { - httpServerCommandHint.RemoveFromClassList("error"); + httpServerCommandHint.RemoveFromClassList("http-local-url-error"); } if (MCPServiceLocator.Server.TryGetLocalHttpServerCommand(out var command, out var error)) diff --git a/tools/update_fork.bat b/tools/update_fork.bat new file mode 100755 index 000000000..db70dd242 --- /dev/null +++ b/tools/update_fork.bat @@ -0,0 +1,17 @@ +@echo off +setlocal + +git checkout main +if errorlevel 1 exit /b 1 + +git fetch -ap upstream +if errorlevel 1 exit /b 1 + +git fetch -ap +if errorlevel 1 exit /b 1 + +git rebase upstream/main +if errorlevel 1 exit /b 1 + +git push +if errorlevel 1 exit /b 1 diff --git a/tools/update_fork.sh b/tools/update_fork.sh new file mode 100755 index 000000000..dab783b06 --- /dev/null +++ b/tools/update_fork.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail + +git checkout main +git fetch -ap upstream +git fetch -ap +git rebase upstream/main +git push