CoplayDev/unity-mcp · error · RuntimeError
Expected file not found: {f}
Error message
Expected file not found: {f} What it means
Raised inside the temporary staging directory after copying MCPForUnity: one of four hardcoded files (SetupWindowService.cs, MCPForUnityMenu.cs, HttpEndpointUtility.cs, McpConnectionSection.cs) is missing from the staged copy. This is a structural-integrity guard — the release script applies string replacements to these files, so they must exist at the expected relative paths.
Source
Thrown at tools/prepare_unity_asset_store_release.py:139
print("[dry-run] Would stage a temporary copy of MCPForUnity and apply Asset Store edits there.")
print(
f"[dry-run] Would replace:\n- {dest_mcp}\n with\n- {source_mcp}")
return 0
# 1) Stage a temporary copy of MCPForUnity and apply Asset Store-specific edits there.
with tempfile.TemporaryDirectory(prefix="mcpforunity_assetstore_") as tmpdir:
staged_mcp = Path(tmpdir) / "MCPForUnity"
shutil.copytree(source_mcp, staged_mcp)
setup_service = staged_mcp / "Editor" / "Setup" / "SetupWindowService.cs"
menu_file = staged_mcp / "Editor" / "MenuItems" / "MCPForUnityMenu.cs"
http_util = staged_mcp / "Editor" / "Helpers" / "HttpEndpointUtility.cs"
connection_section = staged_mcp / "Editor" / "Windows" / \
"Components" / "Connection" / "McpConnectionSection.cs"
for f in (setup_service, menu_file, http_util, connection_section):
if not f.is_file():
raise RuntimeError(f"Expected file not found: {f}")
# Remove auto-popup setup window for Asset Store packaging
remove_line_exact(setup_service, "[InitializeOnLoad]")
# Set default remote base URL to the hosted endpoint
replace_once(
http_util,
r'private const string DefaultRemoteBaseUrl = "";',
f'private const string DefaultRemoteBaseUrl = "{remote_url}";',
)
# Default transport to HTTP Remote and persist inferred scope when missing
replace_once(
connection_section,
r'transportDropdown\.Init\(TransportProtocol\.HTTPLocal\);',
'transportDropdown.Init(TransportProtocol.HTTPRemote);',
)
replace_once(View on GitHub (pinned to c21bf496bc)
Solutions
- Check the error path in the message — it names the specific missing file.
- Locate the file's current path in MCPForUnity/Editor/ and update the corresponding variable in the script (setup_service, menu_file, http_util, or connection_section).
- If the file was removed entirely, determine whether the corresponding source edit is still needed and remove that edit step.
Example fix
# before setup_service = staged_mcp / "Editor" / "Setup" / "SetupWindowService.cs" # after — updated after the file moved during refactor setup_service = staged_mcp / "Editor" / "Windows" / "Setup" / "SetupWindowService.cs"
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
expected_files = [
"Editor/Setup/SetupWindowService.cs",
"Editor/MenuItems/MCPForUnityMenu.cs",
"Editor/Helpers/HttpEndpointUtility.cs",
"Editor/Windows/Components/Connection/McpConnectionSection.cs",
]
source_mcp = Path("MCPForUnity").resolve()
missing = [f for f in expected_files if not (source_mcp / f).is_file()]
if missing:
raise SystemExit(f"Missing expected files in MCPForUnity: {missing}") Prevention
- Run --dry-run first to validate paths before staging and editing.
- When restructuring MCPForUnity/Editor/, update the hardcoded paths in this script in the same PR.
- Add a CI check that runs the release script in dry-run mode to catch path drift early.
When it happens
Trigger: Any of the four files was renamed, moved, or deleted in a repo restructure. The script copies the live MCPForUnity tree, so the staged copy mirrors the current source layout. If Editor/Setup/SetupWindowService.cs, Editor/MenuItems/MCPForUnityMenu.cs, Editor/Helpers/HttpEndpointUtility.cs, or Editor/Windows/Components/Connection/McpConnectionSection.cs no longer sits at that exact path, the loop raises.
Common situations: A refactoring PR reorganized the Editor/ folder hierarchy; a file was split or merged; the script was written against an older layout than the current branch.
Related errors
- Source MCPForUnity folder not found: {source_mcp}
- Assets folder not found: {assets_dir}
- {path}: expected to remove exactly 1 line '{line}', removed
- Package file not found: {PACKAGE_JSON}
- --remote-url must be a non-empty URL
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/37a236b16deb0950.
Report an issue: GitHub.