-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstall.sh
More file actions
436 lines (413 loc) · 10.3 KB
/
Copy pathinstall.sh
File metadata and controls
436 lines (413 loc) · 10.3 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
#!/usr/bin/env bash
set -e
echo ""
echo " ============================================"
echo " UnrealMCP Setup"
echo " Configure MCP for your AI tool"
echo " ============================================"
echo ""
# Check for Python
PYTHON=""
if command -v python3 &>/dev/null; then
PYTHON="python3"
elif command -v python &>/dev/null; then
PYTHON="python"
else
echo " [ERROR] Python not found. Please install Python 3.10+."
echo " macOS: brew install python"
echo " Linux: sudo apt install python3 python3-pip"
exit 1
fi
echo " [OK] Python found: $($PYTHON --version)"
echo ""
# Install pip package
echo " Installing unrealmcp Python package..."
$PYTHON -m pip install unrealmcp -q 2>/dev/null || $PYTHON -m pip install --user unrealmcp -q 2>/dev/null || true
if command -v unrealmcp &>/dev/null; then
echo " [OK] unrealmcp command ready"
else
echo " [ERROR] unrealmcp command not found after install."
echo " You may need to add Python scripts to your PATH."
exit 1
fi
echo ""
# ============================================
# Detect where we are
# ============================================
SCOPE=""
PROJECT_ROOT=""
UPROJECT=""
IN_ENGINE=0
# Search upward for .uproject
SEARCH_DIR="$(pwd)"
while [ "$SEARCH_DIR" != "/" ]; do
FOUND=$(ls "$SEARCH_DIR"/*.uproject 2>/dev/null | head -1)
if [ -n "$FOUND" ]; then
UPROJECT="$(basename "$FOUND")"
PROJECT_ROOT="$SEARCH_DIR"
break
fi
SEARCH_DIR="$(dirname "$SEARCH_DIR")"
done
# Check if we're inside an Engine folder
CHECK_DIR="$(pwd)"
while [ "$CHECK_DIR" != "/" ]; do
DIRNAME="$(basename "$CHECK_DIR")"
if [ "$DIRNAME" = "Engine" ] || [ "$DIRNAME" = "engine" ]; then
IN_ENGINE=1
break
fi
CHECK_DIR="$(dirname "$CHECK_DIR")"
done
# Decide scope
if [ -n "$UPROJECT" ] && [ $IN_ENGINE -eq 0 ]; then
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 ""
read -p " Enter choice (1-2): " SCOPE_CHOICE
if [ "$SCOPE_CHOICE" = "2" ]; then
SCOPE="GLOBAL"
else
SCOPE="PROJECT"
fi
elif [ $IN_ENGINE -eq 1 ]; then
echo " Detected: Inside Unreal Engine folder"
echo " MCP config will be set globally (user-level)."
echo ""
SCOPE="GLOBAL"
else
echo " No UE project or engine detected."
echo " MCP config will be set globally (user-level)."
echo ""
SCOPE="GLOBAL"
fi
# ============================================
# Helper: check if unrealmcp already in a file
# ============================================
check_has_unrealmcp() {
local file="$1"
if [ -f "$file" ] && grep -qi "unrealmcp" "$file" 2>/dev/null; then
return 0
fi
return 1
}
# ============================================
# Helper: merge unreal entry into existing JSON
# Uses python since it's already installed
# ============================================
merge_mcp_entry() {
local file="$1"
local root_key="$2"
local extra="$3"
$PYTHON -c "
import json, sys
f = '$file'
with open(f) as fh:
data = json.load(fh)
if '$root_key' not in data:
data['$root_key'] = {}
entry = {'command': 'unrealmcp', 'args': [], 'env': {}}
${extra}
data['$root_key']['unreal'] = entry
with open(f, 'w') as fh:
json.dump(data, fh, indent=2)
fh.write('\n')
"
echo " [OK] Added unrealmcp to $file"
}
# ============================================
# Config writers
# ============================================
setup_claude() {
local target
if [ "$SCOPE" = "PROJECT" ]; then
target="$PROJECT_ROOT/.mcp.json"
else
target="$HOME/.claude.json"
fi
if check_has_unrealmcp "$target"; then
echo " [OK] Claude Code - already configured in $target"
return
fi
if [ -f "$target" ]; then
merge_mcp_entry "$target" "mcpServers" "entry['type'] = 'stdio'"
return
fi
cat > "$target" << 'EOF'
{
"mcpServers": {
"unreal": {
"type": "stdio",
"command": "unrealmcp",
"args": [],
"env": {}
}
}
}
EOF
echo " [OK] Claude Code - $target"
}
setup_cursor() {
local target
if [ "$SCOPE" = "PROJECT" ]; then
target="$PROJECT_ROOT/.cursor/mcp.json"
mkdir -p "$PROJECT_ROOT/.cursor"
else
target="$HOME/.cursor/mcp.json"
mkdir -p "$HOME/.cursor"
fi
if check_has_unrealmcp "$target"; then
echo " [OK] Cursor - already configured in $target"
return
fi
if [ -f "$target" ]; then
merge_mcp_entry "$target" "mcpServers" ""
return
fi
cat > "$target" << 'EOF'
{
"mcpServers": {
"unreal": {
"command": "unrealmcp",
"args": [],
"env": {}
}
}
}
EOF
echo " [OK] Cursor - $target"
}
setup_vscode() {
local target
if [ "$SCOPE" = "PROJECT" ]; then
target="$PROJECT_ROOT/.vscode/mcp.json"
mkdir -p "$PROJECT_ROOT/.vscode"
else
target="$HOME/.vscode/mcp.json"
mkdir -p "$HOME/.vscode"
fi
if check_has_unrealmcp "$target"; then
echo " [OK] VS Code - already configured in $target"
return
fi
if [ -f "$target" ]; then
merge_mcp_entry "$target" "servers" ""
return
fi
cat > "$target" << 'EOF'
{
"servers": {
"unreal": {
"command": "unrealmcp",
"args": [],
"env": {}
}
}
}
EOF
echo " [OK] VS Code - $target"
}
setup_windsurf() {
local target="$HOME/.codeium/windsurf/mcp_config.json"
mkdir -p "$HOME/.codeium/windsurf"
if check_has_unrealmcp "$target"; then
echo " [OK] Windsurf - already configured in $target"
return
fi
if [ -f "$target" ]; then
merge_mcp_entry "$target" "mcpServers" ""
return
fi
cat > "$target" << 'EOF'
{
"mcpServers": {
"unreal": {
"command": "unrealmcp",
"args": [],
"env": {}
}
}
}
EOF
echo " [OK] Windsurf - $target"
}
setup_gemini() {
local target
if [ "$SCOPE" = "PROJECT" ]; then
target="$PROJECT_ROOT/.gemini/settings.json"
mkdir -p "$PROJECT_ROOT/.gemini"
else
target="$HOME/.gemini/settings.json"
mkdir -p "$HOME/.gemini"
fi
if check_has_unrealmcp "$target"; then
echo " [OK] Gemini CLI - already configured in $target"
return
fi
if [ -f "$target" ]; then
merge_mcp_entry "$target" "mcpServers" ""
return
fi
cat > "$target" << 'EOF'
{
"mcpServers": {
"unreal": {
"command": "unrealmcp",
"args": [],
"env": {}
}
}
}
EOF
echo " [OK] Gemini CLI - $target"
}
setup_jetbrains() {
local target
if [ "$SCOPE" = "PROJECT" ]; then
target="$PROJECT_ROOT/.junie/mcp/mcp.json"
mkdir -p "$PROJECT_ROOT/.junie/mcp"
else
echo " [INFO] JetBrains: Configure via Settings > Tools > MCP Server in your IDE"
echo " Command: unrealmcp"
return
fi
if check_has_unrealmcp "$target"; then
echo " [OK] JetBrains - already configured in $target"
return
fi
if [ -f "$target" ]; then
echo " [INFO] JetBrains uses array format. Please add manually:"
echo ' { "name": "unreal", "command": "unrealmcp", "args": [] }'
return
fi
cat > "$target" << 'EOF'
{
"servers": [
{
"name": "unreal",
"command": "unrealmcp",
"args": [],
"env": {}
}
]
}
EOF
echo " [OK] JetBrains - $target"
}
setup_zed() {
local target="$HOME/.config/zed/settings.json"
if check_has_unrealmcp "$target"; then
echo " [OK] Zed - already configured in $target"
return
fi
if [ -f "$target" ]; then
echo " [INFO] Zed settings.json exists. Please add manually:"
echo ' "context_servers": { "unreal": { "source": "custom", "command": { "path": "unrealmcp" } } }'
return
fi
mkdir -p "$HOME/.config/zed"
cat > "$target" << 'EOF'
{
"context_servers": {
"unreal": {
"source": "custom",
"command": {
"path": "unrealmcp",
"args": [],
"env": {}
}
}
}
}
EOF
echo " [OK] Zed - $target"
}
setup_amazonq() {
local target
if [ "$SCOPE" = "PROJECT" ]; then
target="$PROJECT_ROOT/.amazonq/mcp.json"
mkdir -p "$PROJECT_ROOT/.amazonq"
else
target="$HOME/.aws/amazonq/mcp.json"
mkdir -p "$HOME/.aws/amazonq"
fi
if check_has_unrealmcp "$target"; then
echo " [OK] Amazon Q - already configured in $target"
return
fi
if [ -f "$target" ]; then
merge_mcp_entry "$target" "mcpServers" ""
return
fi
cat > "$target" << 'EOF'
{
"mcpServers": {
"unreal": {
"command": "unrealmcp",
"args": [],
"env": {}
}
}
}
EOF
echo " [OK] Amazon Q - $target"
}
# ============================================
# Choose AI tool
# ============================================
echo ""
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 ""
read -p " Enter choice (0-9): " TOOL_CHOICE
case "${TOOL_CHOICE:-0}" in
1) setup_claude ;;
2) setup_cursor ;;
3) setup_vscode ;;
4) setup_windsurf ;;
5) setup_gemini ;;
6) setup_jetbrains ;;
7) setup_zed ;;
8) setup_amazonq ;;
9)
setup_claude
setup_cursor
setup_vscode
setup_windsurf
setup_gemini
setup_jetbrains
setup_zed
setup_amazonq
;;
0) echo " [SKIP] No config created" ;;
esac
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 ""