-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstall.bat
More file actions
458 lines (429 loc) · 11.5 KB
/
Copy pathinstall.bat
File metadata and controls
458 lines (429 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
@echo off
setlocal enabledelayedexpansion
echo.
echo ============================================
echo UnrealMCP Setup
echo Configure MCP for your AI tool
echo ============================================
echo.
:: Check for Python
python --version >nul 2>&1
if errorlevel 1 (
echo [ERROR] Python not found. Please install Python 3.10+ and add it to PATH.
echo Download: https://www.python.org/downloads/
echo.
pause
exit /b 1
)
echo [OK] Python found
for /f "tokens=*" %%v in ('python --version 2^>^&1') do echo %%v
echo.
:: Install pip package
echo Installing unrealmcp Python package...
pip install unrealmcp >nul 2>&1
if errorlevel 1 (
echo [WARN] pip install failed. Trying with --user flag...
pip install --user unrealmcp >nul 2>&1
)
where unrealmcp >nul 2>&1
if errorlevel 1 (
echo [ERROR] unrealmcp command not found after install.
echo You may need to add Python Scripts to your PATH.
pause
exit /b 1
)
echo [OK] unrealmcp command ready
echo.
:: ============================================
:: Detect where we are
:: ============================================
set "SCOPE="
set "PROJECT_ROOT="
set "UPROJECT="
:: Search upward for .uproject (handles running from subfolders like Plugins\UnrealMCP)
set "SEARCH_DIR=%CD%"
:find_uproject
for %%f in ("!SEARCH_DIR!\*.uproject") do (
set "UPROJECT=%%~nxf"
set "PROJECT_ROOT=!SEARCH_DIR!"
)
if not defined UPROJECT (
for %%d in ("!SEARCH_DIR!\..") do set "PARENT=%%~fd"
if not "!PARENT!"=="!SEARCH_DIR!" (
set "SEARCH_DIR=!PARENT!"
goto :find_uproject
)
)
:: Check if we're inside an Engine folder
set "IN_ENGINE=0"
set "CHECK_DIR=%CD%"
:check_engine
for %%d in ("!CHECK_DIR!") do set "DIRNAME=%%~nxd"
if /i "!DIRNAME!"=="Engine" set "IN_ENGINE=1"
if !IN_ENGINE!==0 (
for %%d in ("!CHECK_DIR!\..") do set "CHECK_PARENT=%%~fd"
if not "!CHECK_PARENT!"=="!CHECK_DIR!" (
set "CHECK_DIR=!CHECK_PARENT!"
goto :check_engine
)
)
if defined UPROJECT if !IN_ENGINE!==0 goto :scope_project
if !IN_ENGINE!==1 goto :scope_engine
goto :scope_global
:scope_project
echo Detected: UE project - !UPROJECT!
echo Location: !PROJECT_ROOT!
echo.
echo Where should the MCP config be created?
echo.
echo 1^) This project only (project scope^)
echo 2^) All projects (global scope^)
echo.
set /p SCOPE_CHOICE=" Enter choice (1-2): "
if "!SCOPE_CHOICE!"=="2" (
set "SCOPE=GLOBAL"
) else (
set "SCOPE=PROJECT"
)
goto :scope_done
:scope_engine
echo Detected: Inside Unreal Engine folder
echo MCP config will be set globally (user-level^).
echo.
set "SCOPE=GLOBAL"
goto :scope_done
:scope_global
echo No UE project or engine detected.
echo MCP config will be set globally (user-level^).
echo.
set "SCOPE=GLOBAL"
:scope_done
echo.
:: ============================================
:: Choose AI tool
:: ============================================
echo Which AI tool do you want to configure?
echo.
echo 1) Claude Code
echo 2) Cursor
echo 3) VS Code / Copilot
echo 4) Windsurf
echo 5) Gemini CLI
echo 6) JetBrains / Rider
echo 7) Zed
echo 8) Amazon Q
echo 9) All of the above
echo 0) Skip
echo.
set /p TOOL_CHOICE=" Enter choice (0-9): "
if "%TOOL_CHOICE%"=="1" call :setup_claude
if "%TOOL_CHOICE%"=="2" call :setup_cursor
if "%TOOL_CHOICE%"=="3" call :setup_vscode
if "%TOOL_CHOICE%"=="4" call :setup_windsurf
if "%TOOL_CHOICE%"=="5" call :setup_gemini
if "%TOOL_CHOICE%"=="6" call :setup_jetbrains
if "%TOOL_CHOICE%"=="7" call :setup_zed
if "%TOOL_CHOICE%"=="8" call :setup_amazonq
if "%TOOL_CHOICE%"=="9" (
call :setup_claude
call :setup_cursor
call :setup_vscode
call :setup_windsurf
call :setup_gemini
call :setup_jetbrains
call :setup_zed
call :setup_amazonq
)
if "%TOOL_CHOICE%"=="0" echo [SKIP] No config created
echo.
echo ============================================
echo Setup complete!
echo ============================================
echo.
echo Next steps:
echo 1. Restart your AI tool (Claude Code, Cursor, etc.) to load the new config
echo 2. Open your project in Unreal Editor
echo 3. Check Output Log for: "MCP Bridge initialized on port XXXXX"
echo 4. Open your AI tool in the project directory
echo 5. Try: "Use the health_check tool"
echo.
echo Docs: https://github.com/aadeshrao123/Unreal-MCP
echo Help: https://github.com/aadeshrao123/Unreal-MCP/issues
echo.
pause
exit /b 0
:: ================================================================
:: Helper: Check if unrealmcp already configured in a file
:: Sets ALREADY_HAS=1 if "unrealmcp" found in file, else 0
:: ================================================================
:check_has_unrealmcp
set "ALREADY_HAS=0"
if exist "!TARGET!" (
findstr /i "unrealmcp" "!TARGET!" >nul 2>nul && set "ALREADY_HAS=1"
)
exit /b
:: ================================================================
:: Helper: Merge unreal entry into existing mcpServers JSON
:: Uses PowerShell to safely add to existing config
:: ARG1 = server key path (mcpServers or servers)
:: ARG2 = extra fields (e.g. "type":"stdio",)
:: ================================================================
:merge_mcp_entry
set "ROOT_KEY=%~1"
set "EXTRA=%~2"
powershell -NoProfile -Command ^
"$f='!TARGET!'; $j=Get-Content $f -Raw | ConvertFrom-Json; " ^
"if (-not $j.'!ROOT_KEY!') { $j | Add-Member -Name '!ROOT_KEY!' -Value ([PSCustomObject]@{}) -MemberType NoteProperty }; " ^
"$entry = [PSCustomObject]@{ !EXTRA! command='unrealmcp'; args=@(); env=[PSCustomObject]@{} }; " ^
"$j.'!ROOT_KEY!' | Add-Member -Name 'unreal' -Value $entry -MemberType NoteProperty -Force; " ^
"$j | ConvertTo-Json -Depth 10 | Set-Content $f -Encoding UTF8"
echo [OK] Added unrealmcp to !TARGET!
exit /b
:: ================================================================
:: Config writers
:: PROJECT = write to PROJECT_ROOT, GLOBAL = user-level
:: ================================================================
:: ---- Claude Code ----
:setup_claude
if "!SCOPE!"=="PROJECT" (
set "TARGET=!PROJECT_ROOT!\.mcp.json"
) else (
set "TARGET=%USERPROFILE%\.claude.json"
)
call :check_has_unrealmcp
if !ALREADY_HAS!==1 (
echo [OK] Claude Code - already configured in !TARGET!
exit /b
)
if exist "!TARGET!" (
call :merge_mcp_entry "mcpServers" "'type'='stdio';"
exit /b
)
(
echo {
echo "mcpServers": {
echo "unreal": {
echo "type": "stdio",
echo "command": "unrealmcp",
echo "args": [],
echo "env": {}
echo }
echo }
echo }
) > "!TARGET!"
echo [OK] Claude Code - !TARGET!
exit /b
:: ---- Cursor ----
:setup_cursor
if "!SCOPE!"=="PROJECT" (
set "TARGET=!PROJECT_ROOT!\.cursor\mcp.json"
if not exist "!PROJECT_ROOT!\.cursor" mkdir "!PROJECT_ROOT!\.cursor"
) else (
set "TARGET=%USERPROFILE%\.cursor\mcp.json"
if not exist "%USERPROFILE%\.cursor" mkdir "%USERPROFILE%\.cursor"
)
call :check_has_unrealmcp
if !ALREADY_HAS!==1 (
echo [OK] Cursor - already configured in !TARGET!
exit /b
)
if exist "!TARGET!" (
call :merge_mcp_entry "mcpServers" ""
exit /b
)
(
echo {
echo "mcpServers": {
echo "unreal": {
echo "command": "unrealmcp",
echo "args": [],
echo "env": {}
echo }
echo }
echo }
) > "!TARGET!"
echo [OK] Cursor - !TARGET!
exit /b
:: ---- VS Code / Copilot ----
:setup_vscode
if "!SCOPE!"=="PROJECT" (
set "TARGET=!PROJECT_ROOT!\.vscode\mcp.json"
if not exist "!PROJECT_ROOT!\.vscode" mkdir "!PROJECT_ROOT!\.vscode"
) else (
set "TARGET=%USERPROFILE%\.vscode\mcp.json"
if not exist "%USERPROFILE%\.vscode" mkdir "%USERPROFILE%\.vscode"
)
call :check_has_unrealmcp
if !ALREADY_HAS!==1 (
echo [OK] VS Code - already configured in !TARGET!
exit /b
)
if exist "!TARGET!" (
call :merge_mcp_entry "servers" ""
exit /b
)
(
echo {
echo "servers": {
echo "unreal": {
echo "command": "unrealmcp",
echo "args": [],
echo "env": {}
echo }
echo }
echo }
) > "!TARGET!"
echo [OK] VS Code - !TARGET!
exit /b
:: ---- Windsurf (always user-level) ----
:setup_windsurf
set "TARGET=%USERPROFILE%\.codeium\windsurf\mcp_config.json"
if not exist "%USERPROFILE%\.codeium\windsurf" mkdir "%USERPROFILE%\.codeium\windsurf"
call :check_has_unrealmcp
if !ALREADY_HAS!==1 (
echo [OK] Windsurf - already configured in !TARGET!
exit /b
)
if exist "!TARGET!" (
call :merge_mcp_entry "mcpServers" ""
exit /b
)
(
echo {
echo "mcpServers": {
echo "unreal": {
echo "command": "unrealmcp",
echo "args": [],
echo "env": {}
echo }
echo }
echo }
) > "!TARGET!"
echo [OK] Windsurf - !TARGET!
exit /b
:: ---- Gemini CLI ----
:setup_gemini
if "!SCOPE!"=="PROJECT" (
set "TARGET=!PROJECT_ROOT!\.gemini\settings.json"
if not exist "!PROJECT_ROOT!\.gemini" mkdir "!PROJECT_ROOT!\.gemini"
) else (
set "TARGET=%USERPROFILE%\.gemini\settings.json"
if not exist "%USERPROFILE%\.gemini" mkdir "%USERPROFILE%\.gemini"
)
call :check_has_unrealmcp
if !ALREADY_HAS!==1 (
echo [OK] Gemini CLI - already configured in !TARGET!
exit /b
)
if exist "!TARGET!" (
call :merge_mcp_entry "mcpServers" ""
exit /b
)
(
echo {
echo "mcpServers": {
echo "unreal": {
echo "command": "unrealmcp",
echo "args": [],
echo "env": {}
echo }
echo }
echo }
) > "!TARGET!"
echo [OK] Gemini CLI - !TARGET!
exit /b
:: ---- JetBrains / Rider ----
:setup_jetbrains
if "!SCOPE!"=="PROJECT" (
set "TARGET=!PROJECT_ROOT!\.junie\mcp\mcp.json"
if not exist "!PROJECT_ROOT!\.junie\mcp" mkdir "!PROJECT_ROOT!\.junie\mcp"
) else (
echo [INFO] JetBrains: Configure via Settings ^> Tools ^> MCP Server in your IDE
echo Command: unrealmcp
exit /b
)
call :check_has_unrealmcp
if !ALREADY_HAS!==1 (
echo [OK] JetBrains - already configured in !TARGET!
exit /b
)
if exist "!TARGET!" (
echo [INFO] JetBrains uses array format. Please add manually:
echo { "name": "unreal", "command": "unrealmcp", "args": [] }
exit /b
)
(
echo {
echo "servers": [
echo {
echo "name": "unreal",
echo "command": "unrealmcp",
echo "args": [],
echo "env": {}
echo }
echo ]
echo }
) > "!TARGET!"
echo [OK] JetBrains - !TARGET!
exit /b
:: ---- Zed (always user-level) ----
:setup_zed
set "TARGET=%APPDATA%\Zed\settings.json"
call :check_has_unrealmcp
if !ALREADY_HAS!==1 (
echo [OK] Zed - already configured in !TARGET!
exit /b
)
if exist "!TARGET!" (
echo [INFO] Zed settings.json exists. Please add manually:
echo "context_servers": { "unreal": { "source": "custom", "command": { "path": "unrealmcp" } } }
exit /b
)
if not exist "%APPDATA%\Zed" mkdir "%APPDATA%\Zed"
(
echo {
echo "context_servers": {
echo "unreal": {
echo "source": "custom",
echo "command": {
echo "path": "unrealmcp",
echo "args": [],
echo "env": {}
echo }
echo }
echo }
echo }
) > "!TARGET!"
echo [OK] Zed - !TARGET!
exit /b
:: ---- Amazon Q ----
:setup_amazonq
if "!SCOPE!"=="PROJECT" (
set "TARGET=!PROJECT_ROOT!\.amazonq\mcp.json"
if not exist "!PROJECT_ROOT!\.amazonq" mkdir "!PROJECT_ROOT!\.amazonq"
) else (
set "TARGET=%USERPROFILE%\.aws\amazonq\mcp.json"
if not exist "%USERPROFILE%\.aws\amazonq" mkdir "%USERPROFILE%\.aws\amazonq"
)
call :check_has_unrealmcp
if !ALREADY_HAS!==1 (
echo [OK] Amazon Q - already configured in !TARGET!
exit /b
)
if exist "!TARGET!" (
call :merge_mcp_entry "mcpServers" ""
exit /b
)
(
echo {
echo "mcpServers": {
echo "unreal": {
echo "command": "unrealmcp",
echo "args": [],
echo "env": {}
echo }
echo }
echo }
) > "!TARGET!"
echo [OK] Amazon Q - !TARGET!
exit /b