Skip to content

Commit da31e4c

Browse files
authored
Revert "Bug fix and batch customization (#727)"
This reverts commit ad3756e.
1 parent 038a39e commit da31e4c

12 files changed

Lines changed: 13 additions & 267 deletions

File tree

‎.claude/skills/unity-mcp-skill/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ batch_execute(
5353
)
5454
```
5555

56-
**Max 25 commands per batch by default (configurable in Unity MCP Tools window, max 100).** Use `fail_fast=True` for dependent operations.
56+
**Max 25 commands per batch.** Use `fail_fast=True` for dependent operations. Batches are not transactional (no rollback on partial failure).
5757

5858
### 3. Use `screenshot` in manage_scene to Verify Visual Results
5959

‎.claude/skills/unity-mcp-skill/references/workflows.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ batch_execute(fail_fast=True, commands=[
829829
830830
### Complete Example: Main Menu Screen
831831

832-
Combines multiple templates into a full menu screen in two batch calls (default 25 command limit per batch, configurable in Unity MCP Tools window up to 100).
832+
Combines multiple templates into a full menu screen in two batch calls (25 command limit per batch).
833833

834834
```python
835835
# Batch 1: Canvas + EventSystem + Panel + Title

‎MCPForUnity/Editor/Constants/EditorPrefKeys.cs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,5 @@ internal static class EditorPrefKeys
6363
internal const string CustomerUuid = "MCPForUnity.CustomerUUID";
6464

6565
internal const string ApiKey = "MCPForUnity.ApiKey";
66-
67-
internal const string BatchExecuteMaxCommands = "MCPForUnity.BatchExecute.MaxCommands";
6866
}
6967
}

‎MCPForUnity/Editor/Helpers/AssetPathUtility.cs‎

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ public static JObject GetPackageJson()
201201
/// Gets the package source for the MCP server (used with uvx --from).
202202
/// Checks for EditorPrefs override first (supports git URLs, file:// paths, etc.),
203203
/// then falls back to PyPI package reference.
204-
/// When the override is a local path, auto-corrects to the "Server" subdirectory
205-
/// if the path doesn't contain pyproject.toml but Server/pyproject.toml exists.
206204
/// </summary>
207205
/// <returns>Package source string for uvx --from argument</returns>
208206
public static string GetMcpServerPackageSource()
@@ -211,14 +209,7 @@ public static string GetMcpServerPackageSource()
211209
string sourceOverride = EditorPrefs.GetString(EditorPrefKeys.GitUrlOverride, "");
212210
if (!string.IsNullOrEmpty(sourceOverride))
213211
{
214-
string resolved = ResolveLocalServerPath(sourceOverride);
215-
// Persist the corrected path so future reads are consistent
216-
if (resolved != sourceOverride)
217-
{
218-
EditorPrefs.SetString(EditorPrefKeys.GitUrlOverride, resolved);
219-
McpLog.Info($"Auto-corrected server source override from '{sourceOverride}' to '{resolved}'");
220-
}
221-
return resolved;
212+
return sourceOverride;
222213
}
223214

224215
// Default to PyPI package (avoids Windows long path issues with git clone)
@@ -232,59 +223,6 @@ public static string GetMcpServerPackageSource()
232223
return $"mcpforunityserver=={version}";
233224
}
234225

235-
/// <summary>
236-
/// Validates and auto-corrects a local server source path to ensure it points to the
237-
/// directory containing pyproject.toml. If the path points to a parent directory
238-
/// (e.g. the repo root "unity-mcp") instead of the Python package directory ("Server"),
239-
/// this checks for a "Server" subdirectory with pyproject.toml and returns that path.
240-
/// Non-local paths (URLs, PyPI references) are returned unchanged.
241-
/// </summary>
242-
internal static string ResolveLocalServerPath(string path)
243-
{
244-
if (string.IsNullOrEmpty(path))
245-
return path;
246-
247-
// Skip non-local paths (git URLs, PyPI package names, etc.)
248-
if (path.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
249-
path.StartsWith("https://", StringComparison.OrdinalIgnoreCase) ||
250-
path.StartsWith("git+", StringComparison.OrdinalIgnoreCase) ||
251-
path.StartsWith("ssh://", StringComparison.OrdinalIgnoreCase))
252-
{
253-
return path;
254-
}
255-
256-
// If it looks like a PyPI package reference (no path separators), skip
257-
if (!path.Contains('/') && !path.Contains('\\') && !path.StartsWith("file:", StringComparison.OrdinalIgnoreCase))
258-
{
259-
return path;
260-
}
261-
262-
// Strip file:// prefix for filesystem checks, preserve for return value
263-
string checkPath = path;
264-
string prefix = string.Empty;
265-
if (checkPath.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
266-
{
267-
prefix = checkPath.Substring(0, 7); // preserve original casing
268-
checkPath = checkPath.Substring(7);
269-
}
270-
271-
// Already correct — pyproject.toml exists at this path
272-
if (System.IO.File.Exists(System.IO.Path.Combine(checkPath, "pyproject.toml")))
273-
{
274-
return path;
275-
}
276-
277-
// Check if "Server" subdirectory contains pyproject.toml
278-
string serverSubDir = System.IO.Path.Combine(checkPath, "Server");
279-
if (System.IO.File.Exists(System.IO.Path.Combine(serverSubDir, "pyproject.toml")))
280-
{
281-
return prefix + serverSubDir;
282-
}
283-
284-
// Return as-is; uvx will report the error if the path is truly invalid
285-
return path;
286-
}
287-
288226
/// <summary>
289227
/// Deprecated: Use GetMcpServerPackageSource() instead.
290228
/// Kept for backwards compatibility.

‎MCPForUnity/Editor/Services/EditorStateCache.cs‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ private sealed class EditorStateSnapshot
7575

7676
[JsonProperty("transport")]
7777
public EditorStateTransport Transport { get; set; }
78-
79-
[JsonProperty("settings")]
80-
public EditorStateSettings Settings { get; set; }
8178
}
8279

8380
private sealed class EditorStateUnity
@@ -242,12 +239,6 @@ private sealed class EditorStateTransport
242239
public long? LastMessageUnixMs { get; set; }
243240
}
244241

245-
private sealed class EditorStateSettings
246-
{
247-
[JsonProperty("batch_execute_max_commands")]
248-
public int BatchExecuteMaxCommands { get; set; }
249-
}
250-
251242
static EditorStateCache()
252243
{
253244
try
@@ -491,10 +482,6 @@ private static JObject BuildSnapshot(string reason)
491482
{
492483
UnityBridgeConnected = null,
493484
LastMessageUnixMs = null
494-
},
495-
Settings = new EditorStateSettings
496-
{
497-
BatchExecuteMaxCommands = Tools.BatchExecute.GetMaxCommandsPerBatch()
498485
}
499486
};
500487

‎MCPForUnity/Editor/Tools/BatchExecute.cs‎

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
4-
using MCPForUnity.Editor.Constants;
54
using MCPForUnity.Editor.Helpers;
65
using Newtonsoft.Json.Linq;
7-
using UnityEditor;
86

97
namespace MCPForUnity.Editor.Tools
108
{
@@ -15,20 +13,7 @@ namespace MCPForUnity.Editor.Tools
1513
[McpForUnityTool("batch_execute", AutoRegister = false)]
1614
public static class BatchExecute
1715
{
18-
/// <summary>Default limit when no EditorPrefs override is set.</summary>
19-
internal const int DefaultMaxCommandsPerBatch = 25;
20-
21-
/// <summary>Hard ceiling to prevent extreme editor freezes regardless of user setting.</summary>
22-
internal const int AbsoluteMaxCommandsPerBatch = 100;
23-
24-
/// <summary>
25-
/// Returns the user-configured max commands per batch, clamped between 1 and <see cref="AbsoluteMaxCommandsPerBatch"/>.
26-
/// </summary>
27-
internal static int GetMaxCommandsPerBatch()
28-
{
29-
int configured = EditorPrefs.GetInt(EditorPrefKeys.BatchExecuteMaxCommands, DefaultMaxCommandsPerBatch);
30-
return Math.Clamp(configured, 1, AbsoluteMaxCommandsPerBatch);
31-
}
16+
private const int MaxCommandsPerBatch = 25;
3217

3318
public static async Task<object> HandleCommand(JObject @params)
3419
{
@@ -43,11 +28,9 @@ public static async Task<object> HandleCommand(JObject @params)
4328
return new ErrorResponse("Provide at least one command entry in 'commands'.");
4429
}
4530

46-
int maxCommands = GetMaxCommandsPerBatch();
47-
if (commandsToken.Count > maxCommands)
31+
if (commandsToken.Count > MaxCommandsPerBatch)
4832
{
49-
return new ErrorResponse(
50-
$"A maximum of {maxCommands} commands are allowed per batch (configurable in MCP Tools window, hard max {AbsoluteMaxCommandsPerBatch}).");
33+
return new ErrorResponse($"A maximum of {MaxCommandsPerBatch} commands are allowed per batch.");
5134
}
5235

5336
bool failFast = @params.Value<bool?>("failFast") ?? false;

‎MCPForUnity/Editor/Windows/Components/Advanced/McpAdvancedSection.cs‎

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,6 @@ private void RegisterCallbacks()
158158
}
159159
else
160160
{
161-
url = ResolveServerPath(url);
162-
// Update the text field if the path was auto-corrected, without re-triggering the callback
163-
if (url != evt.newValue?.Trim())
164-
{
165-
gitUrlOverride.SetValueWithoutNotify(url);
166-
}
167161
EditorPrefs.SetString(EditorPrefKeys.GitUrlOverride, url);
168162
}
169163
OnGitUrlChanged?.Invoke();
@@ -332,10 +326,9 @@ private void OnClearUvxClicked()
332326

333327
private void OnBrowseGitUrlClicked()
334328
{
335-
string picked = EditorUtility.OpenFolderPanel("Select Server folder (containing pyproject.toml)", string.Empty, string.Empty);
329+
string picked = EditorUtility.OpenFolderPanel("Select Server folder", string.Empty, string.Empty);
336330
if (!string.IsNullOrEmpty(picked))
337331
{
338-
picked = ResolveServerPath(picked);
339332
gitUrlOverride.value = picked;
340333
EditorPrefs.SetString(EditorPrefKeys.GitUrlOverride, picked);
341334
OnGitUrlChanged?.Invoke();
@@ -344,54 +337,6 @@ private void OnBrowseGitUrlClicked()
344337
}
345338
}
346339

347-
/// <summary>
348-
/// Validates and auto-corrects a local server path to ensure it points to the directory
349-
/// containing pyproject.toml (the Python package root). If the user selects a parent
350-
/// directory (e.g. the repo root), this checks for a "Server" subdirectory with
351-
/// pyproject.toml and returns that instead.
352-
/// </summary>
353-
private static string ResolveServerPath(string path)
354-
{
355-
if (string.IsNullOrEmpty(path))
356-
return path;
357-
358-
// If path is not a local filesystem path, return as-is (git URLs, PyPI refs, etc.)
359-
if (path.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
360-
path.StartsWith("https://", StringComparison.OrdinalIgnoreCase) ||
361-
path.StartsWith("git+", StringComparison.OrdinalIgnoreCase) ||
362-
path.StartsWith("ssh://", StringComparison.OrdinalIgnoreCase))
363-
{
364-
return path;
365-
}
366-
367-
// Strip file:// prefix for filesystem checks, but preserve it for the return value
368-
string checkPath = path;
369-
string prefix = string.Empty;
370-
if (checkPath.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
371-
{
372-
prefix = "file://";
373-
checkPath = checkPath.Substring(7);
374-
}
375-
376-
// Already points to a directory with pyproject.toml — correct path
377-
if (File.Exists(Path.Combine(checkPath, "pyproject.toml")))
378-
{
379-
return path;
380-
}
381-
382-
// Check if "Server" subdirectory contains pyproject.toml (common repo structure)
383-
string serverSubDir = Path.Combine(checkPath, "Server");
384-
if (File.Exists(Path.Combine(serverSubDir, "pyproject.toml")))
385-
{
386-
string corrected = prefix + serverSubDir;
387-
McpLog.Info($"Auto-corrected server path to 'Server' subdirectory: {corrected}");
388-
return corrected;
389-
}
390-
391-
// Return as-is; uvx will report the error if the path is invalid
392-
return path;
393-
}
394-
395340
private void UpdateDeploymentSection()
396341
{
397342
var deployService = MCPServiceLocator.Deployment;

‎MCPForUnity/Editor/Windows/Components/Tools/McpToolsSection.cs‎

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,6 @@ private VisualElement CreateToolRow(ToolMetadata tool)
220220
row.Add(CreateManageSceneActions());
221221
}
222222

223-
if (IsBatchExecuteTool(tool))
224-
{
225-
row.Add(CreateBatchExecuteSettings());
226-
}
227-
228223
return row;
229224
}
230225

@@ -301,52 +296,6 @@ private VisualElement CreateManageSceneActions()
301296
return actions;
302297
}
303298

304-
private VisualElement CreateBatchExecuteSettings()
305-
{
306-
var container = new VisualElement();
307-
container.AddToClassList("tool-item-actions");
308-
container.style.flexDirection = FlexDirection.Row;
309-
container.style.alignItems = Align.Center;
310-
container.style.marginTop = 4;
311-
312-
var label = new Label("Max commands per batch:");
313-
label.style.marginRight = 8;
314-
label.style.unityFontStyleAndWeight = UnityEngine.FontStyle.Normal;
315-
container.Add(label);
316-
317-
int currentValue = EditorPrefs.GetInt(
318-
EditorPrefKeys.BatchExecuteMaxCommands,
319-
BatchExecute.DefaultMaxCommandsPerBatch
320-
);
321-
322-
var field = new IntegerField
323-
{
324-
value = Math.Clamp(currentValue, 1, BatchExecute.AbsoluteMaxCommandsPerBatch),
325-
style = { width = 60 }
326-
};
327-
field.tooltip = $"Number of commands allowed per batch_execute call (1–{BatchExecute.AbsoluteMaxCommandsPerBatch}). Default: {BatchExecute.DefaultMaxCommandsPerBatch}.";
328-
329-
field.RegisterValueChangedCallback(evt =>
330-
{
331-
int clamped = Math.Clamp(evt.newValue, 1, BatchExecute.AbsoluteMaxCommandsPerBatch);
332-
if (clamped != evt.newValue)
333-
{
334-
field.SetValueWithoutNotify(clamped);
335-
}
336-
EditorPrefs.SetInt(EditorPrefKeys.BatchExecuteMaxCommands, clamped);
337-
});
338-
339-
container.Add(field);
340-
341-
var hint = new Label($"(max {BatchExecute.AbsoluteMaxCommandsPerBatch})");
342-
hint.style.marginLeft = 4;
343-
hint.style.color = new UnityEngine.Color(0.5f, 0.5f, 0.5f);
344-
hint.style.fontSize = 10;
345-
container.Add(hint);
346-
347-
return container;
348-
}
349-
350299
private void OnManageSceneScreenshotClicked()
351300
{
352301
try
@@ -380,8 +329,6 @@ private static Label CreateTag(string text)
380329

381330
private static bool IsManageSceneTool(ToolMetadata tool) => string.Equals(tool?.Name, "manage_scene", StringComparison.OrdinalIgnoreCase);
382331

383-
private static bool IsBatchExecuteTool(ToolMetadata tool) => string.Equals(tool?.Name, "batch_execute", StringComparison.OrdinalIgnoreCase);
384-
385332
private static bool IsBuiltIn(ToolMetadata tool) => tool?.IsBuiltIn ?? false;
386333
}
387334
}

‎Server/src/services/resources/editor_state.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ class EditorStateTransport(BaseModel):
9191
last_message_unix_ms: int | None = None
9292

9393

94-
class EditorStateSettings(BaseModel):
95-
batch_execute_max_commands: int | None = None
96-
97-
9894
class EditorStateAdvice(BaseModel):
9995
ready_for_tools: bool | None = None
10096
blocking_reasons: list[str] | None = None
@@ -118,7 +114,6 @@ class EditorStateData(BaseModel):
118114
assets: EditorStateAssets | None = None
119115
tests: EditorStateTests | None = None
120116
transport: EditorStateTransport | None = None
121-
settings: EditorStateSettings | None = None
122117
advice: EditorStateAdvice | None = None
123118
staleness: EditorStateStaleness | None = None
124119

0 commit comments

Comments
 (0)