2025-11-28 06:18:44 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using MCPForUnity.Editor.Constants;
|
|
|
|
|
using MCPForUnity.Editor.Models;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
|
|
|
|
namespace MCPForUnity.Editor.Clients.Configurators
|
|
|
|
|
{
|
|
|
|
|
public class ClaudeDesktopConfigurator : JsonFileMcpConfigurator
|
|
|
|
|
{
|
2025-12-02 10:01:14 +08:00
|
|
|
public const string ClientName = "Claude Desktop";
|
|
|
|
|
|
2025-11-28 06:18:44 +08:00
|
|
|
public ClaudeDesktopConfigurator() : base(new McpClient
|
|
|
|
|
{
|
2025-12-02 10:01:14 +08:00
|
|
|
name = ClientName,
|
2025-11-28 06:18:44 +08:00
|
|
|
windowsConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Claude", "claude_desktop_config.json"),
|
|
|
|
|
macConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Application Support", "Claude", "claude_desktop_config.json"),
|
|
|
|
|
linuxConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config", "Claude", "claude_desktop_config.json"),
|
2025-12-02 10:01:14 +08:00
|
|
|
SupportsHttpTransport = false,
|
|
|
|
|
StripEnvWhenNotRequired = true
|
2025-11-28 06:18:44 +08:00
|
|
|
})
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
public override IList<string> GetInstallationSteps() => new List<string>
|
|
|
|
|
{
|
|
|
|
|
"Open Claude Desktop",
|
|
|
|
|
"Go to Settings > Developer > Edit Config\nOR open the config path",
|
|
|
|
|
"Paste the configuration JSON",
|
|
|
|
|
"Save and restart Claude Desktop"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public override void Configure()
|
|
|
|
|
{
|
|
|
|
|
bool useHttp = EditorPrefs.GetBool(EditorPrefKeys.UseHttpTransport, true);
|
|
|
|
|
if (useHttp)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Claude Desktop does not support HTTP transport. Switch to stdio in settings before configuring.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.Configure();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetManualSnippet()
|
|
|
|
|
{
|
|
|
|
|
bool useHttp = EditorPrefs.GetBool(EditorPrefKeys.UseHttpTransport, true);
|
|
|
|
|
if (useHttp)
|
|
|
|
|
{
|
|
|
|
|
return "# Claude Desktop does not support HTTP transport.\n" +
|
|
|
|
|
"# Open Advanced Settings and disable HTTP transport to use stdio, then regenerate.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.GetManualSnippet();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|