@echo off chcp 65001 >nul setlocal rem --------------------------------------------------------------------------- rem code-review-graph MCP launcher for PI-Desktop. rem rem The MCP host spawns this with a minimal environment (PATH, SystemRoot, rem windir, TEMP, TMP, LANG plus the manifest's env block) and cwd = plugin rem directory, with stdin/stdout used for JSON-RPC. Never write to stdout. rem --------------------------------------------------------------------------- if defined CRG_HOME goto have_home set "CRG_HOME=D:\github-project\code-review-graph" :have_home rem code_review_graph/constants.py calls Path.home() at import time; without a rem user profile the server dies with "Could not determine home directory.". if defined USERPROFILE goto have_profile set "USERPROFILE=C:\Users\%USERNAME%" :have_profile if defined HOMEDRIVE goto have_hd set "HOMEDRIVE=C:" :have_hd if defined HOMEPATH goto have_hp set "HOMEPATH=\Users\%USERNAME%" :have_hp if defined APPDATA set "APPDATA=%USERPROFILE%\AppData\Roaming" if defined LOCALAPPDATA set "LOCALAPPDATA=%USERPROFILE%\AppData\Local" set "PYTHONUTF8=1" set "PYTHONIOENCODING=utf-8" rem The editable install's .pth points at D:\github_project\... (underscore) rem while the checkout lives at D:\github-project\... (hyphen), so the package rem is only importable with the checkout explicitly on sys.path. set "PYTHONPATH=%CRG_HOME%" rem The venv's code-review-graph.exe is a broken uv trampoline rem ("failed to canonicalize script path"), so prefer a working interpreter. set "CRG_PY=%CRG_HOME%\.venv\Scripts\python.exe" if exist "%CRG_PY%" goto py_ready set "CRG_PY=python" :py_ready rem Upstream ships 30 tools; keep the surface small unless overridden. if defined CRG_TOOLS goto tools_ready set "CRG_TOOLS=build_or_update_graph_tool,run_postprocess_tool,get_minimal_context_tool,get_review_context_tool,get_impact_radius_tool,query_graph_tool,semantic_search_nodes_tool,detect_changes_tool,list_graph_stats_tool,get_affected_flows_tool" :tools_ready if defined CRG_REPO goto repo_ready set "CRG_REPO=%CRG_HOME%" :repo_ready "%CRG_PY%" -m code_review_graph serve --repo "%CRG_REPO%" endlocal