Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 0 additions & 206 deletions FixscriptableobjecPlan.md

This file was deleted.

15 changes: 13 additions & 2 deletions MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,9 @@ private void Register()
else
{
var (uvxPath, gitUrl, packageName) = AssetPathUtility.GetUvxCommandParts();
args = $"mcp add --transport stdio UnityMCP -- \"{uvxPath}\" --from \"{gitUrl}\" {packageName}";
bool devForceRefresh = GetDevModeForceRefresh();
string devFlags = devForceRefresh ? "--no-cache --refresh " : string.Empty;
args = $"mcp add --transport stdio UnityMCP -- \"{uvxPath}\" {devFlags}--from \"{gitUrl}\" {packageName}";
}

string projectDir = Path.GetDirectoryName(Application.dataPath);
Expand Down Expand Up @@ -537,14 +539,23 @@ public override string GetManualSnippet()
}

string gitUrl = AssetPathUtility.GetMcpServerGitUrl();
bool devForceRefresh = GetDevModeForceRefresh();
string devFlags = devForceRefresh ? "--no-cache --refresh " : string.Empty;

return "# Register the MCP server with Claude Code:\n" +
$"claude mcp add --transport stdio UnityMCP -- \"{uvxPath}\" --from \"{gitUrl}\" mcp-for-unity\n\n" +
$"claude mcp add --transport stdio UnityMCP -- \"{uvxPath}\" {devFlags}--from \"{gitUrl}\" mcp-for-unity\n\n" +
"# Unregister the MCP server:\n" +
"claude mcp remove UnityMCP\n\n" +
"# List registered servers:\n" +
"claude mcp list # Only works when claude is run in the project's directory";
}

private static bool GetDevModeForceRefresh()
{
try { return EditorPrefs.GetBool(EditorPrefKeys.DevModeForceServerRefresh, false); }
catch { return false; }
}

public override IList<string> GetInstallationSteps() => new List<string>
{
"Ensure Claude CLI is installed",
Expand Down
1 change: 1 addition & 0 deletions MCPForUnity/Editor/Constants/EditorPrefKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal static class EditorPrefKeys
internal const string SessionId = "MCPForUnity.SessionId";
internal const string WebSocketUrlOverride = "MCPForUnity.WebSocketUrl";
internal const string GitUrlOverride = "MCPForUnity.GitUrlOverride";
internal const string DevModeForceServerRefresh = "MCPForUnity.DevModeForceServerRefresh";

internal const string PackageDeploySourcePath = "MCPForUnity.PackageDeploy.SourcePath";
internal const string PackageDeployLastBackupPath = "MCPForUnity.PackageDeploy.LastBackupPath";
Expand Down
28 changes: 28 additions & 0 deletions MCPForUnity/Editor/Helpers/CodexConfigHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MCPForUnity.Editor.Constants;
using MCPForUnity.Editor.Services;
using MCPForUnity.External.Tommy;
using UnityEditor;
using UnityEngine;

namespace MCPForUnity.Editor.Helpers
{
Expand All @@ -15,6 +17,26 @@ namespace MCPForUnity.Editor.Helpers
/// </summary>
public static class CodexConfigHelper
{
private static bool GetDevModeForceRefresh()
{
try
{
return EditorPrefs.GetBool(EditorPrefKeys.DevModeForceServerRefresh, false);
}
catch
{
return false;
}
}

private static void AddDevModeArgs(TomlArray args, bool devForceRefresh)
{
if (args == null) return;
if (!devForceRefresh) return;
args.Add(new TomlString { Value = "--no-cache" });
args.Add(new TomlString { Value = "--refresh" });
}

public static string BuildCodexServerBlock(string uvPath)
{
var table = new TomlTable();
Expand All @@ -37,9 +59,12 @@ public static string BuildCodexServerBlock(string uvPath)
{
// Stdio mode: Use command and args
var (uvxPath, fromUrl, packageName) = AssetPathUtility.GetUvxCommandParts();
bool devForceRefresh = GetDevModeForceRefresh();

unityMCP["command"] = uvxPath;

var args = new TomlArray();
AddDevModeArgs(args, devForceRefresh);
if (!string.IsNullOrEmpty(fromUrl))
{
args.Add(new TomlString { Value = "--from" });
Expand Down Expand Up @@ -184,9 +209,12 @@ private static TomlTable CreateUnityMcpTable(string uvPath)
{
// Stdio mode: Use command and args
var (uvxPath, fromUrl, packageName) = AssetPathUtility.GetUvxCommandParts();
bool devForceRefresh = GetDevModeForceRefresh();

unityMCP["command"] = new TomlString { Value = uvxPath };

var argsArray = new TomlArray();
AddDevModeArgs(argsArray, devForceRefresh);
if (!string.IsNullOrEmpty(fromUrl))
{
argsArray.Add(new TomlString { Value = "--from" });
Expand Down
23 changes: 17 additions & 6 deletions MCPForUnity/Editor/Helpers/ConfigJsonBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ private static void PopulateUnityNode(JObject unity, string uvPath, McpClient cl
// Stdio mode: Use uvx command
var (uvxPath, fromUrl, packageName) = AssetPathUtility.GetUvxCommandParts();

var toolArgs = BuildUvxArgs(fromUrl, packageName);
bool devForceRefresh = false;
try { devForceRefresh = EditorPrefs.GetBool(EditorPrefKeys.DevModeForceServerRefresh, false); } catch { }

var toolArgs = BuildUvxArgs(fromUrl, packageName, devForceRefresh);

if (ShouldUseWindowsCmdShim(client))
{
Expand Down Expand Up @@ -149,15 +152,23 @@ private static JObject EnsureObject(JObject parent, string name)
return created;
}

private static IList<string> BuildUvxArgs(string fromUrl, string packageName)
private static IList<string> BuildUvxArgs(string fromUrl, string packageName, bool devForceRefresh)
{
var args = new List<string> { packageName };

// Dev mode: force a fresh install/resolution (avoids stale cached builds while iterating).
// `--no-cache` is the key flag; `--refresh` ensures metadata is revalidated.
// Keep ordering consistent with other uvx builders: dev flags first, then --from <url>, then package name.
var args = new List<string>();
if (devForceRefresh)
{
args.Add("--no-cache");
args.Add("--refresh");
}
if (!string.IsNullOrEmpty(fromUrl))
{
args.Insert(0, fromUrl);
args.Insert(0, "--from");
args.Add("--from");
args.Add(fromUrl);
}
args.Add(packageName);

args.Add("--transport");
args.Add("stdio");
Expand Down
Loading
Loading