Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Comment on lines +688 to +690
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Warning log on bind-only host might be too noisy for common configurations

Since 0.0.0.0/:: is a very common bind address, this warning will fire on every WebSocket connection and clutter logs, even though the situation is handled by remapping to localhost. Consider reducing it to info/debug level, or ensuring it only logs once (e.g., per process or per URL) instead of per connection.

host = "localhost";
}

var builder = new UriBuilder(httpUri)
{
Expand Down
2 changes: 1 addition & 1 deletion MCPForUnity/Editor/Windows/Components/Common.uss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -435,22 +436,24 @@ public void UpdateHttpServerCommandDisplay()

if (!isLocalHttpUrl)
{
httpServerCommandField.value = "<Invalid Localhost URL>";
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))
Expand Down
17 changes: 17 additions & 0 deletions tools/update_fork.bat
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions tools/update_fork.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail

git checkout main
git fetch -ap upstream
git fetch -ap
Comment on lines +5 to +6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Avoid redundant fetch/prune operations in update script

Running git fetch -ap upstream followed by git fetch -ap performs two full fetch/prune cycles. One git fetch -ap is enough to update and prune all remotes (including upstream), or you can just fetch upstream if that’s the only remote needed here.

git rebase upstream/main
git push