Minor fixes (#602)
* Log a message with implicit URI changes Small update for #542 * Log a message with implicit URI changes Small update for #542 * Add helper scripts to update forks * fix: improve HTTP Local URL validation UX and styling specificity - Rename CSS class from generic "error" to "http-local-url-error" for better specificity - Rename "invalid-url" class to "http-local-invalid-url" for clarity - Disable httpServerCommandField when URL is invalid or transport not HTTP Local - Clear field value and tooltip when showing validation errors - Ensure field is re-enabled when URL becomes validmain
parent
1cc582636d
commit
810d756be9
|
|
@ -682,9 +682,14 @@ namespace MCPForUnity.Editor.Services.Transport.Transports
|
||||||
throw new InvalidOperationException($"Invalid MCP base URL: {baseUrl}");
|
throw new InvalidOperationException($"Invalid MCP base URL: {baseUrl}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace 0.0.0.0 with localhost for client connections
|
// Replace bind-only addresses with localhost for client connections
|
||||||
// 0.0.0.0 is only valid for server binding, not client connections
|
// 0.0.0.0 and :: are only valid for server binding, not client connections
|
||||||
string host = httpUri.Host == "0.0.0.0" ? "localhost" : httpUri.Host;
|
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)
|
var builder = new UriBuilder(httpUri)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -437,7 +437,7 @@
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.help-text.error {
|
.help-text.http-local-url-error {
|
||||||
color: rgba(255, 80, 80, 1);
|
color: rgba(255, 80, 80, 1);
|
||||||
-unity-font-style: bold;
|
-unity-font-style: bold;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -420,6 +420,7 @@ namespace MCPForUnity.Editor.Windows.Components.Connection
|
||||||
httpServerCommandSection.style.display = DisplayStyle.None;
|
httpServerCommandSection.style.display = DisplayStyle.None;
|
||||||
httpServerCommandField.value = string.Empty;
|
httpServerCommandField.value = string.Empty;
|
||||||
httpServerCommandField.tooltip = string.Empty;
|
httpServerCommandField.tooltip = string.Empty;
|
||||||
|
httpServerCommandField.SetEnabled(false);
|
||||||
if (httpServerCommandHint != null)
|
if (httpServerCommandHint != null)
|
||||||
{
|
{
|
||||||
httpServerCommandHint.text = string.Empty;
|
httpServerCommandHint.text = string.Empty;
|
||||||
|
|
@ -435,22 +436,24 @@ namespace MCPForUnity.Editor.Windows.Components.Connection
|
||||||
|
|
||||||
if (!isLocalHttpUrl)
|
if (!isLocalHttpUrl)
|
||||||
{
|
{
|
||||||
httpServerCommandField.value = "<Invalid Localhost URL>";
|
httpServerCommandField.value = string.Empty;
|
||||||
httpServerCommandField.tooltip = "The command cannot be generated because the URL is not a local address.";
|
httpServerCommandField.tooltip = string.Empty;
|
||||||
httpServerCommandSection.EnableInClassList("invalid-url", true);
|
httpServerCommandField.SetEnabled(false);
|
||||||
|
httpServerCommandSection.EnableInClassList("http-local-invalid-url", true);
|
||||||
if (httpServerCommandHint != null)
|
if (httpServerCommandHint != null)
|
||||||
{
|
{
|
||||||
httpServerCommandHint.text = "⚠ HTTP Local requires a localhost URL (localhost/127.0.0.1/0.0.0.0/::1).";
|
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);
|
copyHttpServerCommandButton?.SetEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
httpServerCommandSection.EnableInClassList("invalid-url", false);
|
httpServerCommandSection.EnableInClassList("http-local-invalid-url", false);
|
||||||
|
httpServerCommandField.SetEnabled(true);
|
||||||
if (httpServerCommandHint != null)
|
if (httpServerCommandHint != null)
|
||||||
{
|
{
|
||||||
httpServerCommandHint.RemoveFromClassList("error");
|
httpServerCommandHint.RemoveFromClassList("http-local-url-error");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MCPServiceLocator.Server.TryGetLocalHttpServerCommand(out var command, out var error))
|
if (MCPServiceLocator.Server.TryGetLocalHttpServerCommand(out var command, out var error))
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in New Issue