|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.IO; |
| 4 | +using MCPForUnity.Editor.Constants; |
| 5 | +using MCPForUnity.Editor.Models; |
| 6 | +using UnityEditor; |
| 7 | + |
| 8 | +namespace MCPForUnity.Editor.Clients.Configurators |
| 9 | +{ |
| 10 | + public class CherryStudioConfigurator : JsonFileMcpConfigurator |
| 11 | + { |
| 12 | + public const string ClientName = "Cherry Studio"; |
| 13 | + |
| 14 | + public CherryStudioConfigurator() : base(new McpClient |
| 15 | + { |
| 16 | + name = ClientName, |
| 17 | + windowsConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Cherry Studio", "config"), |
| 18 | + macConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Application Support", "Cherry Studio", "config"), |
| 19 | + linuxConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config", "Cherry Studio", "config"), |
| 20 | + SupportsHttpTransport = false |
| 21 | + }) |
| 22 | + { } |
| 23 | + |
| 24 | + public override bool SupportsAutoConfigure => false; |
| 25 | + |
| 26 | + public override IList<string> GetInstallationSteps() => new List<string> |
| 27 | + { |
| 28 | + "Open Cherry Studio", |
| 29 | + "Go to Settings (⚙️) → MCP Server", |
| 30 | + "Click 'Add Server' button", |
| 31 | + "For STDIO mode (recommended):", |
| 32 | + " - Name: unity-mcp", |
| 33 | + " - Type: STDIO", |
| 34 | + " - Command: uvx", |
| 35 | + " - Arguments: Copy from the Manual Configuration JSON below", |
| 36 | + "Click Save and restart Cherry Studio", |
| 37 | + "", |
| 38 | + "Note: Cherry Studio uses UI-based configuration.", |
| 39 | + "Use the manual snippet below as reference for the values to enter." |
| 40 | + }; |
| 41 | + |
| 42 | + public override McpStatus CheckStatus(bool attemptAutoRewrite = true) |
| 43 | + { |
| 44 | + client.SetStatus(McpStatus.NotConfigured, "Cherry Studio requires manual UI configuration"); |
| 45 | + return client.status; |
| 46 | + } |
| 47 | + |
| 48 | + public override void Configure() |
| 49 | + { |
| 50 | + throw new InvalidOperationException( |
| 51 | + "Cherry Studio uses UI-based configuration. " + |
| 52 | + "Please use the Manual Configuration snippet and Installation Steps to configure manually." |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + public override string GetManualSnippet() |
| 57 | + { |
| 58 | + bool useHttp = EditorPrefs.GetBool(EditorPrefKeys.UseHttpTransport, true); |
| 59 | + |
| 60 | + if (useHttp) |
| 61 | + { |
| 62 | + return "# Cherry Studio does not support WebSocket transport.\n" + |
| 63 | + "# Cherry Studio supports STDIO and SSE transports.\n" + |
| 64 | + "# \n" + |
| 65 | + "# To use Cherry Studio:\n" + |
| 66 | + "# 1. Switch transport to 'Stdio' in Advanced Settings below\n" + |
| 67 | + "# 2. Return to this configuration screen\n" + |
| 68 | + "# 3. Copy the STDIO configuration snippet that will appear\n" + |
| 69 | + "# \n" + |
| 70 | + "# OPTION 2: SSE mode (future support)\n" + |
| 71 | + "# Note: Unity MCP does not currently have an SSE endpoint.\n" + |
| 72 | + "# This may be added in a future update."; |
| 73 | + } |
| 74 | + |
| 75 | + return base.GetManualSnippet() + "\n\n" + |
| 76 | + "# Cherry Studio Configuration Instructions:\n" + |
| 77 | + "# Cherry Studio uses UI-based configuration, not a JSON file.\n" + |
| 78 | + "# \n" + |
| 79 | + "# To configure:\n" + |
| 80 | + "# 1. Open Cherry Studio\n" + |
| 81 | + "# 2. Go to Settings (⚙️) → MCP Server\n" + |
| 82 | + "# 3. Click 'Add Server'\n" + |
| 83 | + "# 4. Enter the following values from the JSON above:\n" + |
| 84 | + "# - Name: unity-mcp\n" + |
| 85 | + "# - Type: STDIO\n" + |
| 86 | + "# - Command: (copy 'command' value from JSON)\n" + |
| 87 | + "# - Arguments: (copy 'args' array values, space-separated or as individual entries)\n" + |
| 88 | + "# - Active: true\n" + |
| 89 | + "# 5. Click Save\n" + |
| 90 | + "# 6. Restart Cherry Studio"; |
| 91 | + } |
| 92 | + } |
| 93 | +} |
0 commit comments