Skip to content

Commit 2c1630e

Browse files
committed
refactor: only add env property to config for Windsurf and Kiro clients
If it ain't broke with the other clients, don't fix...
1 parent d28a468 commit 2c1630e

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

TestProjects/UnityMCPTests/Assets/Tests/EditMode/Windows/ManualConfigJsonBuilderTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace MCPForUnityTests.Editor.Windows
88
public class ManualConfigJsonBuilderTests
99
{
1010
[Test]
11-
public void VSCode_ManualJson_HasServersEnvType_NoDisabled()
11+
public void VSCode_ManualJson_HasServers_NoEnv_NoDisabled()
1212
{
1313
var client = new McpClient { name = "VSCode", mcpType = McpTypes.VSCode };
1414
string json = ConfigJsonBuilder.BuildManualConfigJson("/usr/bin/uv", "/path/to/server", client);
@@ -19,7 +19,7 @@ public void VSCode_ManualJson_HasServersEnvType_NoDisabled()
1919
Assert.AreEqual("/usr/bin/uv", (string)unity["command"]);
2020
CollectionAssert.AreEqual(new[] { "run", "--directory", "/path/to/server", "server.py" }, unity["args"].ToObject<string[]>());
2121
Assert.AreEqual("stdio", (string)unity["type"], "VSCode should include type=stdio");
22-
Assert.NotNull(unity["env"], "env should be included");
22+
Assert.IsNull(unity["env"], "env should not be added for VSCode");
2323
Assert.IsNull(unity["disabled"], "disabled should not be added for VSCode");
2424
}
2525

@@ -38,15 +38,15 @@ public void Windsurf_ManualJson_HasMcpServersEnv_DisabledFalse()
3838
}
3939

4040
[Test]
41-
public void Cursor_ManualJson_HasMcpServersEnv_NoDisabled()
41+
public void Cursor_ManualJson_HasMcpServers_NoEnv_NoDisabled()
4242
{
4343
var client = new McpClient { name = "Cursor", mcpType = McpTypes.Cursor };
4444
string json = ConfigJsonBuilder.BuildManualConfigJson("/usr/bin/uv", "/path/to/server", client);
4545

4646
var root = JObject.Parse(json);
4747
var unity = (JObject)root.SelectToken("mcpServers.unityMCP");
4848
Assert.NotNull(unity, "Expected mcpServers.unityMCP node");
49-
Assert.NotNull(unity["env"], "env should be included");
49+
Assert.IsNull(unity["env"], "env should not be added for Cursor");
5050
Assert.IsNull(unity["disabled"], "disabled should not be added for Cursor");
5151
Assert.IsNull(unity["type"], "type should not be added for non-VSCode clients");
5252
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void AddsEnvAndDisabledFalse_ForKiro()
9696
}
9797

9898
[Test]
99-
public void AddsOnlyEnv_ForCursor()
99+
public void DoesNotAddEnvOrDisabled_ForCursor()
100100
{
101101
var configPath = Path.Combine(_tempRoot, "cursor.json");
102102
WriteInitialConfig(configPath, isVSCode:false, command:_fakeUvPath, directory:"/old/path");
@@ -107,12 +107,12 @@ public void AddsOnlyEnv_ForCursor()
107107
var root = JObject.Parse(File.ReadAllText(configPath));
108108
var unity = (JObject)root.SelectToken("mcpServers.unityMCP");
109109
Assert.NotNull(unity, "Expected mcpServers.unityMCP node");
110-
Assert.NotNull(unity["env"], "env should be present for all clients");
110+
Assert.IsNull(unity["env"], "env should not be added for non-Windsurf/Kiro clients");
111111
Assert.IsNull(unity["disabled"], "disabled should not be added for non-Windsurf/Kiro clients");
112112
}
113113

114114
[Test]
115-
public void VSCode_AddsEnv_NoDisabled()
115+
public void DoesNotAddEnvOrDisabled_ForVSCode()
116116
{
117117
var configPath = Path.Combine(_tempRoot, "vscode.json");
118118
WriteInitialConfig(configPath, isVSCode:true, command:_fakeUvPath, directory:"/old/path");
@@ -123,7 +123,7 @@ public void VSCode_AddsEnv_NoDisabled()
123123
var root = JObject.Parse(File.ReadAllText(configPath));
124124
var unity = (JObject)root.SelectToken("servers.unityMCP");
125125
Assert.NotNull(unity, "Expected servers.unityMCP node");
126-
Assert.NotNull(unity["env"], "env should be present for VSCode as well");
126+
Assert.IsNull(unity["env"], "env should not be added for VSCode client");
127127
Assert.IsNull(unity["disabled"], "disabled should not be added for VSCode client");
128128
Assert.AreEqual("stdio", (string)unity["type"], "VSCode entry should include type=stdio");
129129
}

UnityMcpBridge/Editor/Helpers/ConfigJsonBuilder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ private static void PopulateUnityNode(JObject unity, string uvPath, string direc
6262
if (unity["type"] != null) unity.Remove("type");
6363
}
6464

65-
if (unity["env"] == null)
66-
{
67-
unity["env"] = new JObject();
68-
}
69-
7065
if (client != null && (client.mcpType == McpTypes.Windsurf || client.mcpType == McpTypes.Kiro))
7166
{
67+
if (unity["env"] == null)
68+
{
69+
unity["env"] = new JObject();
70+
}
71+
7272
if (unity["disabled"] == null)
7373
{
7474
unity["disabled"] = false;

0 commit comments

Comments
 (0)