diff --git a/MCPForUnity/Editor/Clients/Configurators/KiloCodeConfigurator.cs b/MCPForUnity/Editor/Clients/Configurators/KiloCodeConfigurator.cs index e62b64562..b07c69766 100644 --- a/MCPForUnity/Editor/Clients/Configurators/KiloCodeConfigurator.cs +++ b/MCPForUnity/Editor/Clients/Configurators/KiloCodeConfigurator.cs @@ -13,7 +13,7 @@ public KiloCodeConfigurator() : base(new McpClient windowsConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Code", "User", "globalStorage", "kilocode.kilo-code", "settings", "mcp_settings.json"), macConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Application Support", "Code", "User", "globalStorage", "kilocode.kilo-code", "settings", "mcp_settings.json"), linuxConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config", "Code", "User", "globalStorage", "kilocode.kilo-code", "settings", "mcp_settings.json"), - IsVsCodeLayout = true + IsVsCodeLayout = false }) { } diff --git a/MCPForUnity/Editor/Helpers/ConfigJsonBuilder.cs b/MCPForUnity/Editor/Helpers/ConfigJsonBuilder.cs index 8405068dd..691945ff6 100644 --- a/MCPForUnity/Editor/Helpers/ConfigJsonBuilder.cs +++ b/MCPForUnity/Editor/Helpers/ConfigJsonBuilder.cs @@ -92,20 +92,17 @@ private static void PopulateUnityNode(JObject unity, string uvPath, McpClient cl if (unity["headers"] != null) unity.Remove("headers"); } - if (isVSCode) + // Cline expects streamableHttp for HTTP endpoints. + if (isCline) { - unity["type"] = "http"; + unity["type"] = "streamableHttp"; } - // Also add type for Claude Code (uses mcpServers layout but needs type field) - else if (client?.name == "Claude Code") + else { + // "type" is standard MCP protocol; include for all clients to avoid + // clients that default to SSE when they see a URL without a type field. unity["type"] = "http"; } - // Cline expects streamableHttp for HTTP endpoints. - else if (isCline) - { - unity["type"] = "streamableHttp"; - } } else { @@ -121,20 +118,8 @@ private static void PopulateUnityNode(JObject unity, string uvPath, McpClient cl if (unity["url"] != null) unity.Remove("url"); if (unity["serverUrl"] != null) unity.Remove("serverUrl"); - if (isVSCode) - { - unity["type"] = "stdio"; - } - else if (isCline) - { - unity["type"] = "stdio"; - } - } - - // Remove type for non-VSCode clients (except clients that explicitly require it) - if (!isVSCode && client?.name != "Claude Code" && !isCline && unity["type"] != null) - { - unity.Remove("type"); + // Include type for all clients — standard MCP protocol field. + unity["type"] = "stdio"; } bool requiresEnv = client?.EnsureEnvObject == true; diff --git a/MCPForUnity/Editor/Services/Transport/TransportCommandDispatcher.cs b/MCPForUnity/Editor/Services/Transport/TransportCommandDispatcher.cs index ff9df4394..becc3bd88 100644 --- a/MCPForUnity/Editor/Services/Transport/TransportCommandDispatcher.cs +++ b/MCPForUnity/Editor/Services/Transport/TransportCommandDispatcher.cs @@ -402,7 +402,15 @@ private static void ProcessCommand(string id, PendingCommand pending) } sw?.Stop(); - McpLogRecord.Log(command.type, parameters, logType, "SUCCESS", sw?.ElapsedMilliseconds ?? 0); + + string syncLogStatus = "SUCCESS"; + string syncLogError = null; + if (result is ErrorResponse errResp) + { + syncLogStatus = "ERROR"; + syncLogError = errResp.Error; + } + McpLogRecord.Log(command.type, parameters, logType, syncLogStatus, sw?.ElapsedMilliseconds ?? 0, syncLogError); var response = new { status = "success", result }; pending.TrySetResult(JsonConvert.SerializeObject(response)); diff --git a/MCPForUnity/Editor/Tools/ReadConsole.cs b/MCPForUnity/Editor/Tools/ReadConsole.cs index 3fe95f6b7..84bacebad 100644 --- a/MCPForUnity/Editor/Tools/ReadConsole.cs +++ b/MCPForUnity/Editor/Tools/ReadConsole.cs @@ -248,10 +248,13 @@ bool includeStacktrace try { - // LogEntries requires calling Start/Stop around GetEntries/GetEntryInternal - _startGettingEntriesMethod.Invoke(null, null); - - int totalEntries = (int)_getCountMethod.Invoke(null, null); + // LogEntries requires calling Start/Stop around GetEntries/GetEntryInternal. + // StartGettingEntries() returns the entry count — use it instead of GetCount() + // which may return stale values within an active iteration session. + object startResult = _startGettingEntriesMethod.Invoke(null, null); + int totalEntries = startResult is int startCount + ? startCount + : (int)_getCountMethod.Invoke(null, null); // Create instance to pass to GetEntryInternal - Ensure the type is correct Type logEntryType = typeof(EditorApplication).Assembly.GetType( "UnityEditor.LogEntry" diff --git a/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/WriteToConfigTests.cs b/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/WriteToConfigTests.cs index 59241ba07..8b18ce042 100644 --- a/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/WriteToConfigTests.cs +++ b/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/WriteToConfigTests.cs @@ -408,7 +408,6 @@ private static void InvokeWriteToConfig(string configPath, McpClient client) private static void AssertTransportConfiguration(JObject unity, McpClient client) { bool useHttp = EditorPrefs.GetBool(UseHttpTransportPrefKey, true); - bool isVSCode = client.IsVsCodeLayout; bool isWindsurf = string.Equals(client.HttpUrlProperty, "serverUrl", StringComparison.OrdinalIgnoreCase); if (useHttp) @@ -429,16 +428,9 @@ private static void AssertTransportConfiguration(JObject unity, McpClient client Assert.IsNull(unity["command"], "HTTP transport should remove command"); Assert.IsNull(unity["args"], "HTTP transport should remove args"); - if (isVSCode) - { - Assert.AreEqual("http", (string)unity["type"], - "VSCode entries should advertise HTTP transport"); - } - else - { - Assert.IsNull(unity["type"], - "Non-VSCode entries should not include type metadata in HTTP mode"); - } + // "type" is now included for all clients (standard MCP protocol field). + Assert.AreEqual("http", (string)unity["type"], + "All entries should advertise HTTP transport type"); } else { @@ -458,16 +450,9 @@ private static void AssertTransportConfiguration(JObject unity, McpClient client Assert.AreEqual("stdio", args[transportIndex + 1], "--transport should be followed by stdio mode"); - if (isVSCode) - { - Assert.AreEqual("stdio", (string)unity["type"], - "VSCode entries should advertise stdio transport"); - } - else - { - Assert.IsNull(unity["type"], - "Non-VSCode entries should not include type metadata in stdio mode"); - } + // "type" is now included for all clients (standard MCP protocol field). + Assert.AreEqual("stdio", (string)unity["type"], + "All entries should advertise stdio transport type"); } }