Skip to content

Commit 5583327

Browse files
committed
mcp_source.py: remove duplicate mac-only script; keep cross-platform argparse version (auto-detect manifest/repo; supports interactive/non-interactive)
1 parent cd70728 commit 5583327

File tree

1 file changed

+0
-73
lines changed

1 file changed

+0
-73
lines changed

mcp_source.py

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -164,78 +164,5 @@ def main() -> None:
164164
print("Tip: In Unity, open Package Manager and Refresh to re-resolve packages.")
165165

166166

167-
if __name__ == "__main__":
168-
main()
169-
170-
#!/usr/bin/env python3
171-
import json
172-
import os
173-
import sys
174-
import subprocess
175-
176-
# Defaults for your environment
177-
UNITY_PROJECT = "/Users/davidsarno/ramble" # change if needed
178-
MANIFEST = os.path.join(UNITY_PROJECT, "Packages", "manifest.json")
179-
LOCAL_REPO = "/Users/davidsarno/unity-mcp" # local repo root
180-
PKG_NAME = "com.coplaydev.unity-mcp"
181-
182-
def get_current_branch(repo_path: str) -> str:
183-
result = subprocess.run(
184-
["git", "-C", repo_path, "rev-parse", "--abbrev-ref", "HEAD"],
185-
capture_output=True, text=True
186-
)
187-
if result.returncode != 0:
188-
print("Error: unable to detect current branch from local repo.", file=sys.stderr)
189-
sys.exit(1)
190-
return result.stdout.strip()
191-
192-
def build_options(branch: str):
193-
return [
194-
("[1] Upstream main", "https://github.com/CoplayDev/unity-mcp.git?path=/UnityMcpBridge"),
195-
(f"[2] Remote {branch}", f"https://github.com/dsarno/unity-mcp.git?path=/UnityMcpBridge#{branch}"),
196-
(f"[3] Local {branch}", f"file:{os.path.join(LOCAL_REPO, 'UnityMcpBridge')}"),
197-
]
198-
199-
def read_manifest(path: str):
200-
with open(path, "r", encoding="utf-8") as f:
201-
return json.load(f)
202-
203-
def write_manifest(path: str, data: dict):
204-
with open(path, "w", encoding="utf-8") as f:
205-
json.dump(data, f, indent=2)
206-
f.write("\n")
207-
208-
def main():
209-
# Allow overrides via args: python mcp_source.py [manifest.json] [local_repo]
210-
manifest_path = MANIFEST if len(sys.argv) < 2 else sys.argv[1]
211-
repo_path = LOCAL_REPO if len(sys.argv) < 3 else sys.argv[2]
212-
213-
branch = get_current_branch(repo_path)
214-
options = build_options(branch)
215-
216-
print("Select MCP package source by number:")
217-
for label, _ in options:
218-
print(label)
219-
choice = input("Enter 1-3: ").strip()
220-
if choice not in {"1", "2", "3"}:
221-
print("Invalid selection.", file=sys.stderr)
222-
sys.exit(1)
223-
224-
idx = int(choice) - 1
225-
_, chosen = options[idx]
226-
227-
data = read_manifest(manifest_path)
228-
deps = data.get("dependencies", {})
229-
if PKG_NAME not in deps:
230-
print(f"Error: '{PKG_NAME}' not found in manifest dependencies.", file=sys.stderr)
231-
sys.exit(1)
232-
233-
print(f"\nUpdating {PKG_NAME}{chosen}")
234-
deps[PKG_NAME] = chosen
235-
data["dependencies"] = deps
236-
write_manifest(manifest_path, data)
237-
print(f"Done. Wrote to: {manifest_path}")
238-
print("Tip: In Unity, open Package Manager and Refresh to re-resolve packages.")
239-
240167
if __name__ == "__main__":
241168
main()

0 commit comments

Comments
 (0)