Skip to content

Commit 90daff6

Browse files
committed
Fix on config and log
1 parent 39cbaa5 commit 90daff6

5 files changed

Lines changed: 31 additions & 50 deletions

File tree

MCPForUnity/Editor/Clients/Configurators/KiloCodeConfigurator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public KiloCodeConfigurator() : base(new McpClient
1313
windowsConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Code", "User", "globalStorage", "kilocode.kilo-code", "settings", "mcp_settings.json"),
1414
macConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Application Support", "Code", "User", "globalStorage", "kilocode.kilo-code", "settings", "mcp_settings.json"),
1515
linuxConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config", "Code", "User", "globalStorage", "kilocode.kilo-code", "settings", "mcp_settings.json"),
16-
IsVsCodeLayout = true
16+
IsVsCodeLayout = false
1717
})
1818
{ }
1919

MCPForUnity/Editor/Helpers/ConfigJsonBuilder.cs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,17 @@ private static void PopulateUnityNode(JObject unity, string uvPath, McpClient cl
9292
if (unity["headers"] != null) unity.Remove("headers");
9393
}
9494

95-
if (isVSCode)
95+
// Cline expects streamableHttp for HTTP endpoints.
96+
if (isCline)
9697
{
97-
unity["type"] = "http";
98+
unity["type"] = "streamableHttp";
9899
}
99-
// Also add type for Claude Code (uses mcpServers layout but needs type field)
100-
else if (client?.name == "Claude Code")
100+
else
101101
{
102+
// "type" is standard MCP protocol; include for all clients to avoid
103+
// clients that default to SSE when they see a URL without a type field.
102104
unity["type"] = "http";
103105
}
104-
// Cline expects streamableHttp for HTTP endpoints.
105-
else if (isCline)
106-
{
107-
unity["type"] = "streamableHttp";
108-
}
109106
}
110107
else
111108
{
@@ -121,20 +118,8 @@ private static void PopulateUnityNode(JObject unity, string uvPath, McpClient cl
121118
if (unity["url"] != null) unity.Remove("url");
122119
if (unity["serverUrl"] != null) unity.Remove("serverUrl");
123120

124-
if (isVSCode)
125-
{
126-
unity["type"] = "stdio";
127-
}
128-
else if (isCline)
129-
{
130-
unity["type"] = "stdio";
131-
}
132-
}
133-
134-
// Remove type for non-VSCode clients (except clients that explicitly require it)
135-
if (!isVSCode && client?.name != "Claude Code" && !isCline && unity["type"] != null)
136-
{
137-
unity.Remove("type");
121+
// Include type for all clients — standard MCP protocol field.
122+
unity["type"] = "stdio";
138123
}
139124

140125
bool requiresEnv = client?.EnsureEnvObject == true;

MCPForUnity/Editor/Services/Transport/TransportCommandDispatcher.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,15 @@ private static void ProcessCommand(string id, PendingCommand pending)
402402
}
403403

404404
sw?.Stop();
405-
McpLogRecord.Log(command.type, parameters, logType, "SUCCESS", sw?.ElapsedMilliseconds ?? 0);
405+
406+
string syncLogStatus = "SUCCESS";
407+
string syncLogError = null;
408+
if (result is ErrorResponse errResp)
409+
{
410+
syncLogStatus = "ERROR";
411+
syncLogError = errResp.Error;
412+
}
413+
McpLogRecord.Log(command.type, parameters, logType, syncLogStatus, sw?.ElapsedMilliseconds ?? 0, syncLogError);
406414

407415
var response = new { status = "success", result };
408416
pending.TrySetResult(JsonConvert.SerializeObject(response));

MCPForUnity/Editor/Tools/ReadConsole.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,13 @@ bool includeStacktrace
248248

249249
try
250250
{
251-
// LogEntries requires calling Start/Stop around GetEntries/GetEntryInternal
252-
_startGettingEntriesMethod.Invoke(null, null);
253-
254-
int totalEntries = (int)_getCountMethod.Invoke(null, null);
251+
// LogEntries requires calling Start/Stop around GetEntries/GetEntryInternal.
252+
// StartGettingEntries() returns the entry count — use it instead of GetCount()
253+
// which may return stale values within an active iteration session.
254+
object startResult = _startGettingEntriesMethod.Invoke(null, null);
255+
int totalEntries = startResult is int startCount
256+
? startCount
257+
: (int)_getCountMethod.Invoke(null, null);
255258
// Create instance to pass to GetEntryInternal - Ensure the type is correct
256259
Type logEntryType = typeof(EditorApplication).Assembly.GetType(
257260
"UnityEditor.LogEntry"

TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/WriteToConfigTests.cs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ private static void InvokeWriteToConfig(string configPath, McpClient client)
408408
private static void AssertTransportConfiguration(JObject unity, McpClient client)
409409
{
410410
bool useHttp = EditorPrefs.GetBool(UseHttpTransportPrefKey, true);
411-
bool isVSCode = client.IsVsCodeLayout;
412411
bool isWindsurf = string.Equals(client.HttpUrlProperty, "serverUrl", StringComparison.OrdinalIgnoreCase);
413412

414413
if (useHttp)
@@ -429,16 +428,9 @@ private static void AssertTransportConfiguration(JObject unity, McpClient client
429428
Assert.IsNull(unity["command"], "HTTP transport should remove command");
430429
Assert.IsNull(unity["args"], "HTTP transport should remove args");
431430

432-
if (isVSCode)
433-
{
434-
Assert.AreEqual("http", (string)unity["type"],
435-
"VSCode entries should advertise HTTP transport");
436-
}
437-
else
438-
{
439-
Assert.IsNull(unity["type"],
440-
"Non-VSCode entries should not include type metadata in HTTP mode");
441-
}
431+
// "type" is now included for all clients (standard MCP protocol field).
432+
Assert.AreEqual("http", (string)unity["type"],
433+
"All entries should advertise HTTP transport type");
442434
}
443435
else
444436
{
@@ -458,16 +450,9 @@ private static void AssertTransportConfiguration(JObject unity, McpClient client
458450
Assert.AreEqual("stdio", args[transportIndex + 1],
459451
"--transport should be followed by stdio mode");
460452

461-
if (isVSCode)
462-
{
463-
Assert.AreEqual("stdio", (string)unity["type"],
464-
"VSCode entries should advertise stdio transport");
465-
}
466-
else
467-
{
468-
Assert.IsNull(unity["type"],
469-
"Non-VSCode entries should not include type metadata in stdio mode");
470-
}
453+
// "type" is now included for all clients (standard MCP protocol field).
454+
Assert.AreEqual("stdio", (string)unity["type"],
455+
"All entries should advertise stdio transport type");
471456
}
472457
}
473458

0 commit comments

Comments
 (0)