diff --git a/Editor/MCPEditorWindow.cs b/Editor/MCPEditorWindow.cs index 07a1c0c..a338829 100644 --- a/Editor/MCPEditorWindow.cs +++ b/Editor/MCPEditorWindow.cs @@ -51,7 +51,7 @@ public class MCPConfigServer public class ServerConfig { [JsonProperty("unity_host")] - public string unityHost; + public string unityHost = "localhost"; [JsonProperty("unity_port")] public int unityPort; @@ -147,6 +147,13 @@ public class MCPEditorWindow : EditorWindow LoadServerConfig(); // Reload config if not loaded } + // Validate host is not null + if (string.IsNullOrEmpty(serverConfig.unityHost)) + { + serverConfig.unityHost = "localhost"; // Fallback to localhost if null + UnityEngine.Debug.LogWarning("Unity host was null, defaulting to localhost"); + } + try { using (var client = new TcpClient())