Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
35 changes: 28 additions & 7 deletions UnityMcpBridge/Editor/Tools/ManageScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@ public static object HandleCommand(JObject @params)
namespaceName
);
case "read":
return Response.Error("Deprecated: reads are resources now. Use resources/read with a unity://path or unity://script URI.");
Debug.LogWarning("manage_script.read is deprecated; prefer resources/read. Serving read for backward compatibility.");
return ReadScript(fullPath, relativePath);
case "update":
return Response.Error("Deprecated: use apply_text_edits (small, line/col edits) rather than whole-file replace.");
Debug.LogWarning("manage_script.update is deprecated; prefer apply_text_edits. Serving update for backward compatibility.");
return UpdateScript(fullPath, relativePath, name, contents);
case "delete":
return DeleteScript(fullPath, relativePath);
case "apply_text_edits":
Expand Down Expand Up @@ -226,10 +228,13 @@ public static object HandleCommand(JObject @params)
: Response.Error("Validation failed.", result);
}
case "edit":
return Response.Error("Deprecated: use apply_text_edits. Structured 'edit' mode has been retired in favor of simple text edits.");
Debug.LogWarning("manage_script.edit is deprecated; prefer apply_text_edits. Serving structured edit for backward compatibility.");
var edits = @params["edits"] as JArray;
var options = @params["options"] as JObject;
return EditScript(fullPath, relativePath, name, edits, options);
default:
return Response.Error(
$"Unknown action: '{action}'. Valid actions are: create, read, update, delete."
$"Unknown action: '{action}'. Valid actions are: create, delete, apply_text_edits, validate, read (deprecated), update (deprecated), edit (deprecated)."
);
}
}
Expand Down Expand Up @@ -581,10 +586,26 @@ private static bool TryIndexFromLineCol(string text, int line1, int col1, out in
}
if (i == text.Length) break;
char c = text[i];
if (c == '\n') { line++; col = 1; }
else { col++; }
if (c == '\r')
{
// Treat CRLF as a single newline; skip the LF if present
if (i + 1 < text.Length && text[i + 1] == '\n')
i++;
line++;
col = 1;
}
else if (c == '\n')
{
line++;
col = 1;
}
else
{
col++;
}
}
index = -1; return false;
index = -1;
return false;
}

private static string ComputeSha256(string contents)
Expand Down
9 changes: 9 additions & 0 deletions UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,15 @@ private void CheckMcpConfiguration(McpClient mcpClient)
}
}
}
else
{
// Surface mismatch even if auto-manage is disabled
mcpClient.SetStatus(McpStatus.IncorrectPath);
if (debugLogsEnabled)
{
UnityEngine.Debug.Log($"UnityMCP: IDE config mismatch for '{mcpClient.name}' and auto-manage disabled");
}
}
}
}
else
Expand Down
9 changes: 8 additions & 1 deletion UnityMcpBridge/UnityMcpServer~/src/pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"typeCheckingMode": "basic",
"reportMissingImports": "none"
"reportMissingImports": "none",
"pythonVersion": "3.11",
"executionEnvironments": [
{
"root": ".",
"pythonVersion": "3.11"
}
]
}
3 changes: 3 additions & 0 deletions test_unity_socket_framing.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def main():
s.sendall(header + body_bytes)
resp_len = struct.unpack(">Q", recv_exact(s, 8))[0]
print(f"Response framed length: {resp_len}")
MAX_RESP = 128 * 1024 * 1024
if resp_len <= 0 or resp_len > MAX_RESP:
raise RuntimeError(f"invalid framed length: {resp_len} (max {MAX_RESP})")
resp = recv_exact(s, resp_len)
else:
s.sendall(body_bytes)
Expand Down