setup-windows-en.bat 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. echo ==========================================
  4. echo TrendRadar MCP Setup (Windows)
  5. echo ==========================================
  6. echo:
  7. REM Fix: Use script location instead of current working directory
  8. set "PROJECT_ROOT=%~dp0"
  9. REM Remove trailing backslash
  10. if "%PROJECT_ROOT:~-1%"=="\" set "PROJECT_ROOT=%PROJECT_ROOT:~0,-1%"
  11. echo Project Directory: %PROJECT_ROOT%
  12. echo:
  13. REM Change to project directory
  14. cd /d "%PROJECT_ROOT%"
  15. if %errorlevel% neq 0 (
  16. echo [ERROR] Cannot access project directory
  17. pause
  18. exit /b 1
  19. )
  20. REM Validate project structure
  21. echo [0/4] Validating project structure...
  22. if not exist "pyproject.toml" (
  23. echo [ERROR] pyproject.toml not found in: %PROJECT_ROOT%
  24. echo:
  25. echo This should not happen! Please check:
  26. echo 1. Is setup-windows.bat in the project root?
  27. echo 2. Was the project properly cloned/downloaded?
  28. echo:
  29. echo Files in current directory:
  30. dir /b
  31. echo:
  32. pause
  33. exit /b 1
  34. )
  35. echo [OK] pyproject.toml found
  36. echo:
  37. REM Check Python
  38. echo [1/4] Checking Python...
  39. python --version >nul 2>&1
  40. if %errorlevel% neq 0 (
  41. echo [ERROR] Python not detected. Please install Python 3.10+
  42. echo Download: https://www.python.org/downloads/
  43. pause
  44. exit /b 1
  45. )
  46. for /f "tokens=*" %%i in ('python --version') do echo [OK] %%i
  47. echo:
  48. REM Check UV
  49. echo [2/4] Checking UV...
  50. where uv >nul 2>&1
  51. if %errorlevel% neq 0 (
  52. echo UV not installed, installing automatically...
  53. echo:
  54. echo Trying installation method 1: PowerShell...
  55. powershell -ExecutionPolicy Bypass -Command "try { irm https://astral.sh/uv/install.ps1 | iex; exit 0 } catch { Write-Host 'PowerShell method failed'; exit 1 }"
  56. if %errorlevel% neq 0 (
  57. echo:
  58. echo Method 1 failed. Trying method 2: pip...
  59. python -m pip install --upgrade uv
  60. if %errorlevel% neq 0 (
  61. echo:
  62. echo [ERROR] Automatic installation failed
  63. echo:
  64. echo Please install UV manually using one of these methods:
  65. echo:
  66. echo Method 1 - pip:
  67. echo python -m pip install uv
  68. echo:
  69. echo Method 2 - pipx:
  70. echo pip install pipx
  71. echo pipx install uv
  72. echo:
  73. echo Method 3 - Manual download:
  74. echo Visit: https://docs.astral.sh/uv/getting-started/installation/
  75. echo:
  76. pause
  77. exit /b 1
  78. )
  79. )
  80. echo:
  81. echo [SUCCESS] UV installed successfully!
  82. echo:
  83. echo [IMPORTANT] Please restart your terminal:
  84. echo 1. Close this window
  85. echo 2. Open a new Command Prompt
  86. echo 3. Navigate to: %PROJECT_ROOT%
  87. echo 4. Run: setup-windows.bat
  88. echo:
  89. pause
  90. exit /b 0
  91. ) else (
  92. for /f "tokens=*" %%i in ('uv --version') do echo [OK] %%i
  93. )
  94. echo:
  95. echo [3/4] Installing dependencies...
  96. echo Working directory: %PROJECT_ROOT%
  97. echo:
  98. REM Ensure we're in the project directory
  99. cd /d "%PROJECT_ROOT%"
  100. uv sync
  101. if %errorlevel% neq 0 (
  102. echo:
  103. echo [ERROR] Dependency installation failed
  104. echo:
  105. echo Troubleshooting steps:
  106. echo 1. Check your internet connection
  107. echo 2. Verify Python version ^>= 3.10: python --version
  108. echo 3. Try with verbose output: uv sync --verbose
  109. echo 4. Check if pyproject.toml is valid
  110. echo:
  111. echo Project directory: %PROJECT_ROOT%
  112. echo:
  113. pause
  114. exit /b 1
  115. )
  116. echo:
  117. echo [OK] Dependencies installed successfully
  118. echo:
  119. echo [4/4] Checking configuration file...
  120. if not exist "config\config.yaml" (
  121. echo [WARNING] config\config.yaml not found
  122. if exist "config\config.example.yaml" (
  123. echo:
  124. echo To create your configuration:
  125. echo 1. Copy: copy config\config.example.yaml config\config.yaml
  126. echo 2. Edit: notepad config\config.yaml
  127. echo 3. Add your API keys
  128. )
  129. echo:
  130. ) else (
  131. echo [OK] config\config.yaml exists
  132. )
  133. echo:
  134. REM Get UV path
  135. for /f "tokens=*" %%i in ('where uv 2^>nul') do set "UV_PATH=%%i"
  136. if not defined UV_PATH (
  137. set "UV_PATH=uv"
  138. )
  139. echo:
  140. echo ==========================================
  141. echo Setup Complete!
  142. echo ==========================================
  143. echo:
  144. echo MCP Server Configuration for Claude Desktop:
  145. echo:
  146. echo Command: %UV_PATH%
  147. echo Working Directory: %PROJECT_ROOT%
  148. echo:
  149. echo Arguments (one per line):
  150. echo --directory
  151. echo %PROJECT_ROOT%
  152. echo run
  153. echo python
  154. echo -m
  155. echo mcp_server.server
  156. echo:
  157. echo Configuration guide: README-Cherry-Studio.md
  158. echo:
  159. echo:
  160. pause