Skip to content

Commit 086a94c

Browse files
committed
fix: update mcp_config.json path for mcp-unity server
1 parent 354ca94 commit 086a94c

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Editor/Utils/McpConfigUtils.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,26 +139,26 @@ public static bool AddToCursorConfig(bool useTabsIndentation)
139139
/// <returns>True if successfuly added the config, false otherwise</returns>
140140
private static bool AddToConfigFile(string configFilePath, bool useTabsIndentation, string productName)
141141
{
142-
try
142+
if (string.IsNullOrEmpty(configFilePath))
143143
{
144-
if (string.IsNullOrEmpty(configFilePath))
145-
{
146-
Debug.LogError($"{productName} config file not found. Please make sure {productName} is installed.");
147-
return false;
148-
}
149-
150-
// Generate fresh MCP config JSON
151-
string mcpConfigJson = GenerateMcpConfigJson(useTabsIndentation);
144+
Debug.LogError($"{productName} config file not found. Please make sure {productName} is installed.");
145+
return false;
146+
}
152147

153-
// Parse the MCP config JSON
154-
JObject mcpConfig = JObject.Parse(mcpConfigJson);
148+
// Generate fresh MCP config JSON
149+
string mcpConfigJson = GenerateMcpConfigJson(useTabsIndentation);
155150

151+
// Parse the MCP config JSON
152+
JObject mcpConfig = JObject.Parse(mcpConfigJson);
153+
154+
try
155+
{
156156
// Check if the file exists
157157
if (File.Exists(configFilePath))
158158
{
159159
// Read the existing config
160160
string existingConfigJson = File.ReadAllText(configFilePath);
161-
JObject existingConfig = JObject.Parse(existingConfigJson);
161+
JObject existingConfig = string.IsNullOrEmpty(existingConfigJson) ? new JObject() : JObject.Parse(existingConfigJson);
162162

163163
// Merge the mcpServers from our config into the existing config
164164
if (mcpConfig["mcpServers"] != null && mcpConfig["mcpServers"] is JObject mcpServers)
@@ -212,7 +212,6 @@ private static string GetWindsurfMcpConfigPath()
212212
{
213213
// Windows: %USERPROFILE%/.codeium/windsurf
214214
basePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".codeium/windsurf");
215-
Debug.Log(basePath);
216215
}
217216
else if (Application.platform == RuntimePlatform.OSXEditor)
218217
{
@@ -277,7 +276,6 @@ private static string GetCursorConfigPath()
277276
{
278277
// Windows: %USERPROFILE%/.cursor
279278
basePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".cursor");
280-
Debug.Log(basePath);
281279
}
282280
else if (Application.platform == RuntimePlatform.OSXEditor)
283281
{

0 commit comments

Comments
 (0)