From f8c3023d7c7f1707b209efda9fd84ab238b58ff5 Mon Sep 17 00:00:00 2001 From: Bilal Date: Wed, 22 Oct 2025 22:42:07 +0300 Subject: [PATCH] Update to support Trae --- MCPForUnity/Editor/Data/McpClients.cs | 28 +++++++++++++++++++ MCPForUnity/Editor/Models/McpTypes.cs | 1 + .../Services/ClientConfigurationService.cs | 10 +++++++ .../Windows/ManualConfigEditorWindow.cs | 7 +++++ .../EditMode/Helpers/WriteToConfigTests.cs | 16 +++++++++++ UnityMcpBridge/Editor/Data/McpClients.cs | 25 +++++++++++++++++ UnityMcpBridge/Editor/Models/McpTypes.cs | 1 + .../Windows/ManualConfigEditorWindow.cs | 7 +++++ 8 files changed, 95 insertions(+) diff --git a/MCPForUnity/Editor/Data/McpClients.cs b/MCPForUnity/Editor/Data/McpClients.cs index 6ddf304d..68717510 100644 --- a/MCPForUnity/Editor/Data/McpClients.cs +++ b/MCPForUnity/Editor/Data/McpClients.cs @@ -133,6 +133,34 @@ public class McpClients mcpType = McpTypes.VSCode, configStatus = "Not Configured", }, + // Trae IDE + new() + { + name = "Trae", + // Windows: %AppData%\Trae\mcp.json + windowsConfigPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + "Trae", + "mcp.json" + ), + // macOS: ~/Library/Application Support/Trae/mcp.json + macConfigPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + "Library", + "Application Support", + "Trae", + "mcp.json" + ), + // Linux: ~/.config/Trae/mcp.json + linuxConfigPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + ".config", + "Trae", + "mcp.json" + ), + mcpType = McpTypes.Trae, + configStatus = "Not Configured", + }, // 3) Kiro new() { diff --git a/MCPForUnity/Editor/Models/McpTypes.cs b/MCPForUnity/Editor/Models/McpTypes.cs index a5a03dec..7c864897 100644 --- a/MCPForUnity/Editor/Models/McpTypes.cs +++ b/MCPForUnity/Editor/Models/McpTypes.cs @@ -9,5 +9,6 @@ public enum McpTypes Kiro, VSCode, Windsurf, + Trae, } } diff --git a/MCPForUnity/Editor/Services/ClientConfigurationService.cs b/MCPForUnity/Editor/Services/ClientConfigurationService.cs index 39728e01..dea5358a 100644 --- a/MCPForUnity/Editor/Services/ClientConfigurationService.cs +++ b/MCPForUnity/Editor/Services/ClientConfigurationService.cs @@ -459,6 +459,16 @@ public string GetInstallationSteps(McpClient client) " OR manually run: claude mcp add UnityMCP\n" + "3. Restart Claude Code", + McpTypes.Trae => + "1. Open Trae and go to Settings > MCP\n" + + "2. Select Add Server > Add Manually\n" + + "3. Paste the JSON or point to the mcp.json file\n" + + " Windows: %AppData%\\Trae\\mcp.json\n" + + " macOS: ~/Library/Application Support/Trae/mcp.json\n" + + " Linux: ~/.config/Trae/mcp.json\n" + + "4. For local servers, Node.js (npx) or uvx must be installed\n" + + "5. Save and restart Trae", + _ => "Configuration steps not available for this client." }; diff --git a/MCPForUnity/Editor/Windows/ManualConfigEditorWindow.cs b/MCPForUnity/Editor/Windows/ManualConfigEditorWindow.cs index ecccbef1..ec3f9be9 100644 --- a/MCPForUnity/Editor/Windows/ManualConfigEditorWindow.cs +++ b/MCPForUnity/Editor/Windows/ManualConfigEditorWindow.cs @@ -108,6 +108,13 @@ protected virtual void OnGUI() instructionStyle ); } + else if (mcpClient?.mcpType == McpTypes.Trae) + { + EditorGUILayout.LabelField( + " a) Going to Settings > MCP > Add Server > Add Manually", + instructionStyle + ); + } EditorGUILayout.LabelField(" OR", instructionStyle); EditorGUILayout.LabelField( " b) Opening the configuration file at:", diff --git a/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/WriteToConfigTests.cs b/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/WriteToConfigTests.cs index 88f4118d..f34130d2 100644 --- a/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/WriteToConfigTests.cs +++ b/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Helpers/WriteToConfigTests.cs @@ -128,6 +128,22 @@ public void DoesNotAddEnvOrDisabled_ForVSCode() Assert.AreEqual("stdio", (string)unity["type"], "VSCode entry should include type=stdio"); } + [Test] + public void DoesNotAddEnvOrDisabled_ForTrae() + { + var configPath = Path.Combine(_tempRoot, "trae.json"); + WriteInitialConfig(configPath, isVSCode: false, command: _fakeUvPath, directory: "/old/path"); + + var client = new McpClient { name = "Trae", mcpType = McpTypes.Trae }; + InvokeWriteToConfig(configPath, client); + + var root = JObject.Parse(File.ReadAllText(configPath)); + var unity = (JObject)root.SelectToken("mcpServers.unityMCP"); + Assert.NotNull(unity, "Expected mcpServers.unityMCP node"); + Assert.IsNull(unity["env"], "env should not be added for Trae client"); + Assert.IsNull(unity["disabled"], "disabled should not be added for Trae client"); + } + [Test] public void PreservesExistingEnvAndDisabled() { diff --git a/UnityMcpBridge/Editor/Data/McpClients.cs b/UnityMcpBridge/Editor/Data/McpClients.cs index 9e718847..1616c464 100644 --- a/UnityMcpBridge/Editor/Data/McpClients.cs +++ b/UnityMcpBridge/Editor/Data/McpClients.cs @@ -134,6 +134,31 @@ public class McpClients mcpType = McpTypes.VSCode, configStatus = "Not Configured", }, + // Trae IDE + new() + { + name = "Trae", + windowsConfigPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + "Trae", + "mcp.json" + ), + macConfigPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + "Library", + "Application Support", + "Trae", + "mcp.json" + ), + linuxConfigPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + ".config", + "Trae", + "mcp.json" + ), + mcpType = McpTypes.Trae, + configStatus = "Not Configured", + }, // 3) Kiro new() { diff --git a/UnityMcpBridge/Editor/Models/McpTypes.cs b/UnityMcpBridge/Editor/Models/McpTypes.cs index a5a03dec..7c864897 100644 --- a/UnityMcpBridge/Editor/Models/McpTypes.cs +++ b/UnityMcpBridge/Editor/Models/McpTypes.cs @@ -9,5 +9,6 @@ public enum McpTypes Kiro, VSCode, Windsurf, + Trae, } } diff --git a/UnityMcpBridge/Editor/Windows/ManualConfigEditorWindow.cs b/UnityMcpBridge/Editor/Windows/ManualConfigEditorWindow.cs index ecccbef1..ec3f9be9 100644 --- a/UnityMcpBridge/Editor/Windows/ManualConfigEditorWindow.cs +++ b/UnityMcpBridge/Editor/Windows/ManualConfigEditorWindow.cs @@ -108,6 +108,13 @@ protected virtual void OnGUI() instructionStyle ); } + else if (mcpClient?.mcpType == McpTypes.Trae) + { + EditorGUILayout.LabelField( + " a) Going to Settings > MCP > Add Server > Add Manually", + instructionStyle + ); + } EditorGUILayout.LabelField(" OR", instructionStyle); EditorGUILayout.LabelField( " b) Opening the configuration file at:",