新增godot mcp github copilot
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
WSL2 + Claude Code CLI + Unity MCP + Rust Token Killer 全栈一键部署脚本
|
||||
WSL2 + Claude Code CLI + Unity MCP + Godot MCP Pro + Rust Token Killer 全栈一键部署脚本
|
||||
.DESCRIPTION
|
||||
自动完成以下步骤:
|
||||
1. 启用 WSL2 功能 & 安装 Ubuntu 发行版
|
||||
2. 检测/安装 Windows 本机 Node.js(AI 客户端 MCP 需要)
|
||||
3. WSL2 内安装 Node.js LTS(Claude Code CLI 需要)
|
||||
4. 安装 Claude Code CLI (@anthropic-ai/claude-code)
|
||||
5. 安装 Unity MCP Server(Windows + WSL2 双侧)& 写入各 AI 客户端配置
|
||||
4. 安装 Claude Code CLI (@anthropic-ai/claude-code) + GitHub Copilot CLI
|
||||
5. 安装 Unity MCP Server + Godot MCP Pro(Windows + WSL2 双侧)& 写入各 AI 客户端配置
|
||||
6. 配置 Windows 防火墙放行 MCP Bridge 端口
|
||||
7. 安装 Rust 工具链 & Token Killer (rtk)
|
||||
8. 写入 PowerShell Profile 快捷命令
|
||||
@@ -27,9 +27,10 @@
|
||||
已有 WSL2 可普通终端运行,加 -SkipWSL 跳过 WSL2 安装检查。
|
||||
#>
|
||||
param(
|
||||
[int] $BridgePort = 7890,
|
||||
[string]$InstallDir = "$env:USERPROFILE\unity-mcp-server",
|
||||
[string]$UnityHubPath = "C:\Program Files\Unity Hub\Unity Hub.exe",
|
||||
[int] $BridgePort = 7890,
|
||||
[string]$InstallDir = "$env:USERPROFILE\unity-mcp-server",
|
||||
[string]$UnityHubPath = "C:\Program Files\Unity Hub\Unity Hub.exe",
|
||||
[string]$GodotMcpVersion = "godot-mcp-pro-v1.14.1",
|
||||
[switch]$SkipFirewall,
|
||||
[switch]$SkipWSL
|
||||
)
|
||||
@@ -88,8 +89,8 @@ $UseLmuAuth = ($ANTHROPIC_AUTH_TOKEN -ne "" -and $ANTHROPIC_BASE_URL -ne "https:
|
||||
# ──────────────────────────────────────────────────────────────
|
||||
Write-Host ""
|
||||
Write-Host "╔══════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
|
||||
Write-Host "║ WSL2 + Claude Code CLI + Unity MCP + RTK 全栈部署 ║" -ForegroundColor Cyan
|
||||
Write-Host "║ AnkleBreaker Unity MCP · WSL2 Mirror Mode ║" -ForegroundColor Cyan
|
||||
Write-Host "║ WSL2 + Claude Code + Unity MCP + Godot MCP Pro + RTK ║" -ForegroundColor Cyan
|
||||
Write-Host "║ AnkleBreaker Unity MCP · Godot MCP Pro · WSL2 Mirror ║" -ForegroundColor Cyan
|
||||
Write-Host "╚══════════════════════════════════════════════════════════╝" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
@@ -116,13 +117,26 @@ if ($distroInstalled) {
|
||||
Write-Info "如已安装 WSL2,请加 -SkipWSL 参数或在 .env 设置 SKIP_WSL_INSTALL=true"
|
||||
exit 1
|
||||
}
|
||||
$f1 = Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -ErrorAction SilentlyContinue
|
||||
if ($f1.State -ne "Enabled") {
|
||||
Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -NoRestart | Out-Null
|
||||
}
|
||||
$f2 = Get-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" -ErrorAction SilentlyContinue
|
||||
if ($f2.State -ne "Enabled") {
|
||||
Enable-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" -NoRestart | Out-Null
|
||||
try {
|
||||
$f1 = Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -ErrorAction Stop
|
||||
if ($f1.State -ne "Enabled") {
|
||||
Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -NoRestart | Out-Null
|
||||
}
|
||||
$f2 = Get-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" -ErrorAction Stop
|
||||
if ($f2.State -ne "Enabled") {
|
||||
Enable-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" -NoRestart | Out-Null
|
||||
}
|
||||
} catch {
|
||||
# Fallback: Get-WindowsOptionalFeature 不可用(WMI "没有注册类"),改用 dism.exe
|
||||
Write-Warn "Get-WindowsOptionalFeature 不可用,回退至 dism.exe 启用 Windows 功能..."
|
||||
$dismOut1 = (dism.exe /online /Get-FeatureInfo /FeatureName:Microsoft-Windows-Subsystem-Linux 2>&1) | Out-String
|
||||
if ($dismOut1 -notmatch "State : Enabled") {
|
||||
dism.exe /online /Enable-Feature /FeatureName:Microsoft-Windows-Subsystem-Linux /NoRestart | Out-Null
|
||||
}
|
||||
$dismOut2 = (dism.exe /online /Get-FeatureInfo /FeatureName:VirtualMachinePlatform 2>&1) | Out-String
|
||||
if ($dismOut2 -notmatch "State : Enabled") {
|
||||
dism.exe /online /Enable-Feature /FeatureName:VirtualMachinePlatform /NoRestart | Out-Null
|
||||
}
|
||||
}
|
||||
wsl --update 2>&1 | Out-Null
|
||||
wsl --set-default-version 2 2>&1 | Out-Null
|
||||
@@ -195,32 +209,39 @@ if ($LASTEXITCODE -ne 0) {
|
||||
}
|
||||
Write-OK "WSL2 ($WSL_DISTRO) 连接正常 (root)"
|
||||
|
||||
# ── Step 1a: 配置 .wslconfig(mirrored 网络模式) ────────────
|
||||
# ── Step 1a: 配置 .wslconfig(镜像网络模式仅 Windows 11 22H2+ 支持) ────
|
||||
$wslCfgPath = "$env:USERPROFILE\.wslconfig"
|
||||
$wslCfgContent = @"
|
||||
$osBuild = [System.Environment]::OSVersion.Version.Build
|
||||
$supportsmirror = ($osBuild -ge 22621) # Win11 22H2+
|
||||
$needRestart = $false
|
||||
if ($supportsmirror) {
|
||||
$wslCfgContent = @"
|
||||
[wsl2]
|
||||
networkingMode=mirrored
|
||||
dnsTunneling=true
|
||||
firewall=true
|
||||
autoProxy=true
|
||||
"@
|
||||
$needRestart = $false
|
||||
if (Test-Path $wslCfgPath) {
|
||||
$existing = Get-Content $wslCfgPath -Raw
|
||||
if ($existing -notmatch "networkingMode=mirrored") {
|
||||
if (Test-Path $wslCfgPath) {
|
||||
$existing = Get-Content $wslCfgPath -Raw
|
||||
if ($existing -notmatch "networkingMode=mirrored") {
|
||||
Set-Content $wslCfgPath $wslCfgContent -Encoding UTF8
|
||||
$needRestart = $true
|
||||
Write-OK ".wslconfig 已更新 -> networkingMode=mirrored"
|
||||
}
|
||||
} else {
|
||||
Set-Content $wslCfgPath $wslCfgContent -Encoding UTF8
|
||||
$needRestart = $true
|
||||
Write-OK ".wslconfig 已更新 -> networkingMode=mirrored"
|
||||
Write-OK ".wslconfig 已创建 -> networkingMode=mirrored"
|
||||
}
|
||||
if ($needRestart) {
|
||||
Write-Info "重启 WSL2 以应用镜像网络模式..."
|
||||
wsl --shutdown 2>$null
|
||||
Start-Sleep 3
|
||||
}
|
||||
} else {
|
||||
Set-Content $wslCfgPath $wslCfgContent -Encoding UTF8
|
||||
$needRestart = $true
|
||||
Write-OK ".wslconfig 已创建 -> networkingMode=mirrored"
|
||||
}
|
||||
if ($needRestart) {
|
||||
Write-Info "重启 WSL2 以应用镜像网络模式..."
|
||||
wsl --shutdown 2>$null
|
||||
Start-Sleep 3
|
||||
Write-Warn "当前 Windows 版本(Build $osBuild)不支持 WSL2 镜像网络模式(需要 Windows 11 22H2+ / Build 22621+),已跳过 .wslconfig 镜像配置"
|
||||
Write-Info "WSL2 将使用默认 NAT 网络模式,代理请在 WSL2 内手动配置"
|
||||
}
|
||||
|
||||
# ══════════════════════════════════════════════════════════════
|
||||
@@ -305,9 +326,9 @@ true
|
||||
}
|
||||
|
||||
# ══════════════════════════════════════════════════════════════
|
||||
# Step 4: Claude Code CLI (WSL2)
|
||||
# Step 4: Claude Code CLI + GitHub Copilot CLI (WSL2)
|
||||
# ══════════════════════════════════════════════════════════════
|
||||
Write-Step "4/8 Claude Code CLI"
|
||||
Write-Step "4/8 Claude Code CLI + GitHub Copilot CLI"
|
||||
|
||||
# 检测 WSL2 原生 claude(排除通过 WSL interop 调用的 Windows claude.exe,路径含 /mnt/)
|
||||
$claudeVer = Invoke-WSL @'
|
||||
@@ -337,6 +358,71 @@ true
|
||||
Write-OK "Claude Code 安装完成"
|
||||
}
|
||||
|
||||
# 检测 WSL2 原生 GitHub CLI(排除通过 WSL interop 调用的 Windows gh.exe,路径含 /mnt/)
|
||||
$ghVer = Invoke-WSL @'
|
||||
_g=$(which gh 2>/dev/null)
|
||||
if [ -n "$_g" ] && ! echo "$_g" | grep -q '/mnt/'; then
|
||||
gh --version 2>/dev/null | head -1
|
||||
else
|
||||
echo MISSING
|
||||
fi
|
||||
true
|
||||
'@ -IgnoreError
|
||||
|
||||
$ghCopilotInstalled = Invoke-WSL @'
|
||||
_g=$(which gh 2>/dev/null)
|
||||
if [ -n "$_g" ] && ! echo "$_g" | grep -q '/mnt/'; then
|
||||
gh extension list 2>/dev/null | grep -q 'github/gh-copilot'
|
||||
echo $?
|
||||
else
|
||||
echo 1
|
||||
fi
|
||||
true
|
||||
'@ -IgnoreError
|
||||
|
||||
if ($ghVer -notmatch "MISSING") {
|
||||
Write-OK "GitHub CLI 已安装 (WSL2 原生): $($ghVer.Trim())"
|
||||
} else {
|
||||
Write-Info "安装 GitHub CLI (WSL2 原生)..."
|
||||
$installGhCmd = @'
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
sudo mkdir -p -m 755 /etc/apt/keyrings
|
||||
if [ ! -f /etc/apt/keyrings/githubcli-archive-keyring.gpg ]; then
|
||||
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
|
||||
| sudo dd of=/etc/apt/keyrings/githubcli-archive-keyring.gpg status=none
|
||||
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
|
||||
fi
|
||||
if [ ! -f /etc/apt/sources.list.d/github-cli.list ]; then
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
|
||||
| sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
||||
fi
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq gh
|
||||
gh --version | head -1
|
||||
true
|
||||
'@
|
||||
Invoke-WSL $installGhCmd
|
||||
$ghVer = Invoke-WSL "gh --version 2>/dev/null | head -1 || echo MISSING" -IgnoreError
|
||||
Write-OK "GitHub CLI 安装完成: $($ghVer.Trim())"
|
||||
}
|
||||
|
||||
if ($ghCopilotInstalled.Trim() -eq "0") {
|
||||
Write-OK "GitHub Copilot CLI 扩展已安装 (WSL2 原生)"
|
||||
} else {
|
||||
Write-Info "安装 GitHub Copilot CLI 扩展 (gh-copilot)..."
|
||||
$installGhCopilotCmd = @'
|
||||
if gh extension list 2>/dev/null | grep -q 'github/gh-copilot'; then
|
||||
gh extension upgrade github/gh-copilot 2>/dev/null || true
|
||||
else
|
||||
gh extension install github/gh-copilot
|
||||
fi
|
||||
gh extension list | grep 'github/gh-copilot' || true
|
||||
true
|
||||
'@
|
||||
Invoke-WSL $installGhCopilotCmd
|
||||
Write-OK "GitHub Copilot CLI 扩展已安装(命令入口:gh copilot)"
|
||||
}
|
||||
|
||||
# 写入 Claude 配置(WSL2 侧)— 含 allowedTools 完整白名单(自动信任,无需每次确认)
|
||||
$mcpAllowedTools = @(
|
||||
# Claude 内置工具
|
||||
@@ -398,7 +484,117 @@ $mcpAllowedTools = @(
|
||||
"mcp__unity-mcp__unity_hub_get_install_path","mcp__unity-mcp__unity_hub_set_install_path",
|
||||
# Multi-Instance & Project Context
|
||||
"mcp__unity-mcp__unity_list_instances","mcp__unity-mcp__unity_select_instance",
|
||||
"mcp__unity-mcp__unity_get_project_context"
|
||||
"mcp__unity-mcp__unity_get_project_context",
|
||||
# ─── Godot MCP Pro ───────────────────────────────────────
|
||||
# Project & Filesystem
|
||||
"mcp__godot-mcp-pro__get_project_info","mcp__godot-mcp-pro__get_filesystem_tree",
|
||||
"mcp__godot-mcp-pro__search_files","mcp__godot-mcp-pro__search_in_files",
|
||||
"mcp__godot-mcp-pro__get_project_settings","mcp__godot-mcp-pro__get_project_statistics",
|
||||
"mcp__godot-mcp-pro__uid_to_project_path","mcp__godot-mcp-pro__project_path_to_uid",
|
||||
# Scene
|
||||
"mcp__godot-mcp-pro__get_scene_tree","mcp__godot-mcp-pro__get_scene_file_content",
|
||||
"mcp__godot-mcp-pro__get_scene_exports","mcp__godot-mcp-pro__get_scene_dependencies",
|
||||
"mcp__godot-mcp-pro__create_scene","mcp__godot-mcp-pro__open_scene",
|
||||
"mcp__godot-mcp-pro__save_scene","mcp__godot-mcp-pro__add_scene_instance",
|
||||
# Node
|
||||
"mcp__godot-mcp-pro__get_node_properties","mcp__godot-mcp-pro__get_node_groups",
|
||||
"mcp__godot-mcp-pro__get_signals","mcp__godot-mcp-pro__find_nodes_in_group",
|
||||
"mcp__godot-mcp-pro__find_nodes_by_type","mcp__godot-mcp-pro__find_signal_connections",
|
||||
"mcp__godot-mcp-pro__find_node_references",
|
||||
"mcp__godot-mcp-pro__add_node","mcp__godot-mcp-pro__duplicate_node",
|
||||
"mcp__godot-mcp-pro__move_node","mcp__godot-mcp-pro__rename_node",
|
||||
"mcp__godot-mcp-pro__update_property","mcp__godot-mcp-pro__add_resource",
|
||||
"mcp__godot-mcp-pro__set_anchor_preset",
|
||||
"mcp__godot-mcp-pro__connect_signal","mcp__godot-mcp-pro__disconnect_signal",
|
||||
"mcp__godot-mcp-pro__set_node_groups",
|
||||
"mcp__godot-mcp-pro__batch_set_property","mcp__godot-mcp-pro__cross_scene_set_property",
|
||||
# Script
|
||||
"mcp__godot-mcp-pro__list_scripts","mcp__godot-mcp-pro__read_script",
|
||||
"mcp__godot-mcp-pro__get_open_scripts","mcp__godot-mcp-pro__validate_script",
|
||||
"mcp__godot-mcp-pro__create_script","mcp__godot-mcp-pro__edit_script",
|
||||
"mcp__godot-mcp-pro__attach_script",
|
||||
# Editor & Output
|
||||
"mcp__godot-mcp-pro__get_editor_errors","mcp__godot-mcp-pro__get_output_log",
|
||||
"mcp__godot-mcp-pro__get_editor_screenshot","mcp__godot-mcp-pro__get_editor_performance",
|
||||
"mcp__godot-mcp-pro__clear_output","mcp__godot-mcp-pro__reload_plugin",
|
||||
"mcp__godot-mcp-pro__reload_project",
|
||||
# Resource & Shader
|
||||
"mcp__godot-mcp-pro__read_resource","mcp__godot-mcp-pro__get_resource_preview",
|
||||
"mcp__godot-mcp-pro__create_resource","mcp__godot-mcp-pro__edit_resource",
|
||||
"mcp__godot-mcp-pro__read_shader","mcp__godot-mcp-pro__get_shader_params",
|
||||
"mcp__godot-mcp-pro__create_shader","mcp__godot-mcp-pro__edit_shader",
|
||||
"mcp__godot-mcp-pro__assign_shader_material","mcp__godot-mcp-pro__set_shader_param",
|
||||
# Animation
|
||||
"mcp__godot-mcp-pro__list_animations","mcp__godot-mcp-pro__get_animation_info",
|
||||
"mcp__godot-mcp-pro__create_animation","mcp__godot-mcp-pro__add_animation_track",
|
||||
"mcp__godot-mcp-pro__set_animation_keyframe",
|
||||
"mcp__godot-mcp-pro__get_animation_tree_structure",
|
||||
"mcp__godot-mcp-pro__create_animation_tree","mcp__godot-mcp-pro__add_state_machine_state",
|
||||
"mcp__godot-mcp-pro__add_state_machine_transition",
|
||||
"mcp__godot-mcp-pro__set_blend_tree_node","mcp__godot-mcp-pro__set_tree_parameter",
|
||||
# Audio
|
||||
"mcp__godot-mcp-pro__get_audio_bus_layout","mcp__godot-mcp-pro__get_audio_info",
|
||||
"mcp__godot-mcp-pro__add_audio_bus","mcp__godot-mcp-pro__set_audio_bus",
|
||||
"mcp__godot-mcp-pro__add_audio_bus_effect","mcp__godot-mcp-pro__add_audio_player",
|
||||
# Input
|
||||
"mcp__godot-mcp-pro__get_input_actions","mcp__godot-mcp-pro__set_input_action",
|
||||
# 3D & Physics
|
||||
"mcp__godot-mcp-pro__get_physics_layers","mcp__godot-mcp-pro__get_collision_info",
|
||||
"mcp__godot-mcp-pro__set_physics_layers",
|
||||
"mcp__godot-mcp-pro__add_mesh_instance","mcp__godot-mcp-pro__setup_lighting",
|
||||
"mcp__godot-mcp-pro__set_material_3d","mcp__godot-mcp-pro__setup_environment",
|
||||
"mcp__godot-mcp-pro__setup_camera_3d","mcp__godot-mcp-pro__add_gridmap",
|
||||
"mcp__godot-mcp-pro__setup_collision","mcp__godot-mcp-pro__add_raycast",
|
||||
"mcp__godot-mcp-pro__setup_physics_body",
|
||||
# Navigation
|
||||
"mcp__godot-mcp-pro__get_navigation_info",
|
||||
"mcp__godot-mcp-pro__setup_navigation_region","mcp__godot-mcp-pro__bake_navigation_mesh",
|
||||
"mcp__godot-mcp-pro__setup_navigation_agent","mcp__godot-mcp-pro__set_navigation_layers",
|
||||
# Particles
|
||||
"mcp__godot-mcp-pro__get_particle_info",
|
||||
"mcp__godot-mcp-pro__create_particles","mcp__godot-mcp-pro__set_particle_material",
|
||||
"mcp__godot-mcp-pro__set_particle_color_gradient","mcp__godot-mcp-pro__apply_particle_preset",
|
||||
# Theme
|
||||
"mcp__godot-mcp-pro__get_theme_info",
|
||||
"mcp__godot-mcp-pro__create_theme","mcp__godot-mcp-pro__set_theme_color",
|
||||
"mcp__godot-mcp-pro__set_theme_constant","mcp__godot-mcp-pro__set_theme_font_size",
|
||||
"mcp__godot-mcp-pro__set_theme_stylebox",
|
||||
# Tilemap
|
||||
"mcp__godot-mcp-pro__tilemap_get_cell","mcp__godot-mcp-pro__tilemap_get_info",
|
||||
"mcp__godot-mcp-pro__tilemap_get_used_cells",
|
||||
"mcp__godot-mcp-pro__tilemap_set_cell","mcp__godot-mcp-pro__tilemap_fill_rect",
|
||||
# Autoload & Project Settings
|
||||
"mcp__godot-mcp-pro__get_autoload","mcp__godot-mcp-pro__add_autoload",
|
||||
"mcp__godot-mcp-pro__set_project_setting",
|
||||
# Analysis
|
||||
"mcp__godot-mcp-pro__find_unused_resources","mcp__godot-mcp-pro__analyze_signal_flow",
|
||||
"mcp__godot-mcp-pro__analyze_scene_complexity","mcp__godot-mcp-pro__find_script_references",
|
||||
"mcp__godot-mcp-pro__detect_circular_dependencies",
|
||||
"mcp__godot-mcp-pro__get_performance_monitors",
|
||||
# Export
|
||||
"mcp__godot-mcp-pro__get_export_info","mcp__godot-mcp-pro__list_export_presets",
|
||||
# Game Runtime (need play_scene first)
|
||||
"mcp__godot-mcp-pro__play_scene","mcp__godot-mcp-pro__stop_scene",
|
||||
"mcp__godot-mcp-pro__get_game_scene_tree","mcp__godot-mcp-pro__get_game_node_properties",
|
||||
"mcp__godot-mcp-pro__get_game_screenshot","mcp__godot-mcp-pro__set_game_node_property",
|
||||
"mcp__godot-mcp-pro__find_nodes_by_script",
|
||||
# Input Simulation
|
||||
"mcp__godot-mcp-pro__simulate_key","mcp__godot-mcp-pro__simulate_mouse_click",
|
||||
"mcp__godot-mcp-pro__simulate_mouse_move","mcp__godot-mcp-pro__simulate_action",
|
||||
"mcp__godot-mcp-pro__simulate_sequence",
|
||||
# Capture & Recording
|
||||
"mcp__godot-mcp-pro__capture_frames","mcp__godot-mcp-pro__record_frames",
|
||||
"mcp__godot-mcp-pro__monitor_properties","mcp__godot-mcp-pro__batch_get_properties",
|
||||
"mcp__godot-mcp-pro__start_recording","mcp__godot-mcp-pro__stop_recording",
|
||||
"mcp__godot-mcp-pro__replay_recording",
|
||||
# UI & Navigation (Runtime)
|
||||
"mcp__godot-mcp-pro__find_ui_elements","mcp__godot-mcp-pro__click_button_by_text",
|
||||
"mcp__godot-mcp-pro__wait_for_node","mcp__godot-mcp-pro__find_nearby_nodes",
|
||||
"mcp__godot-mcp-pro__navigate_to","mcp__godot-mcp-pro__move_to",
|
||||
# Testing
|
||||
"mcp__godot-mcp-pro__run_test_scenario","mcp__godot-mcp-pro__assert_node_state",
|
||||
"mcp__godot-mcp-pro__assert_screen_text","mcp__godot-mcp-pro__run_stress_test",
|
||||
"mcp__godot-mcp-pro__get_test_report","mcp__godot-mcp-pro__compare_screenshots"
|
||||
)
|
||||
$claudeSettingsJson = if ($UseLmuAuth) {
|
||||
# 灵眸 / 中转 API:使用 env.ANTHROPIC_AUTH_TOKEN(避免与 ANTHROPIC_API_KEY 冲突)
|
||||
@@ -468,7 +664,7 @@ Write-OK "Claude Code 配置已写入(Windows + WSL2)"
|
||||
# ══════════════════════════════════════════════════════════════
|
||||
# Step 5: Unity MCP Server 安装
|
||||
# ══════════════════════════════════════════════════════════════
|
||||
Write-Step "5/8 Unity MCP Server"
|
||||
Write-Step "5/8 MCP Servers (Unity + Godot MCP Pro)"
|
||||
Write-Info "MCP Server: https://github.com/AnkleBreaker-Studio/unity-mcp-server"
|
||||
Write-Info "Unity Plugin: https://github.com/AnkleBreaker-Studio/unity-mcp-plugin"
|
||||
|
||||
@@ -544,7 +740,7 @@ $wslMcpEntry = @{
|
||||
}
|
||||
|
||||
function Merge-McpConfig {
|
||||
param([string]$ConfigFile, [hashtable]$Entry, [string]$Label)
|
||||
param([string]$ConfigFile, [hashtable]$Entry, [string]$Label, [string]$ServerName = "unity-mcp")
|
||||
$dir = Split-Path $ConfigFile
|
||||
if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null }
|
||||
# PS5.1 兼容:手动将 PSCustomObject 转为普通 Hashtable
|
||||
@@ -567,7 +763,7 @@ function Merge-McpConfig {
|
||||
} catch {}
|
||||
}
|
||||
if (-not $cfg.ContainsKey("mcpServers")) { $cfg["mcpServers"] = @{} }
|
||||
$cfg["mcpServers"]["unity-mcp"] = $Entry
|
||||
$cfg["mcpServers"][$ServerName] = $Entry
|
||||
$cfg | ConvertTo-Json -Depth 10 | Set-Content $ConfigFile -Encoding UTF8
|
||||
Write-OK "$Label -> $ConfigFile"
|
||||
}
|
||||
@@ -594,8 +790,90 @@ true
|
||||
Invoke-WSL $wslMcpCfgCmd -IgnoreError | Out-Null
|
||||
Write-OK "Claude Code CLI (WSL2) MCP -> unity-mcp (node $wslScript)"
|
||||
|
||||
# ══════════════════════════════════════════════════════════════
|
||||
# Step 6: Windows 防火墙放行 MCP Bridge 端口
|
||||
# ══════════════════════════════════════════════════════════════# Step 5d: Godot MCP Pro 安装(本地 ZIP 包,无需联网)
|
||||
# ════════════════════════════════════════════════════════════
|
||||
Write-Step "5d Godot MCP Pro"
|
||||
Write-Info "版本目录: $GodotMcpVersion"
|
||||
Write-Info "源目录: $ScriptDir\$GodotMcpVersion"
|
||||
|
||||
$GodotMcpSrcDir = Join-Path $ScriptDir $GodotMcpVersion
|
||||
$GodotMcpSrcSrv = Join-Path $GodotMcpSrcDir "server"
|
||||
$GodotMcpWinDir = Join-Path $env:USERPROFILE "godot-mcp-pro"
|
||||
|
||||
# ── 5d-i. Windows 侧:robocopy 同步 server/,排除 node_modules ─────────────
|
||||
if (Test-Path $GodotMcpSrcSrv) {
|
||||
Write-Info "同步 server/ -> $GodotMcpWinDir"
|
||||
# robocopy 退出码 0-7 均为正常,需屏蔽错误级
|
||||
$rcArgs = @($GodotMcpSrcSrv, $GodotMcpWinDir, "/E", "/XD", "node_modules",
|
||||
"/NFL", "/NDL", "/NJH", "/NJS", "/nc", "/ns", "/np")
|
||||
& robocopy @rcArgs 2>&1 | Out-Null
|
||||
if ($winNodeExists) {
|
||||
Push-Location $GodotMcpWinDir
|
||||
try { & node build/setup.js install 2>&1 | Out-Null } finally { Pop-Location }
|
||||
}
|
||||
$godotWinEntry = @{
|
||||
command = "node"
|
||||
args = @(($GodotMcpWinDir -replace "\\", "/") + "/build/index.js")
|
||||
}
|
||||
Merge-McpConfig "$env:APPDATA\Claude\claude_desktop_config.json" $godotWinEntry "Claude Desktop (Godot MCP Pro)" "godot-mcp-pro"
|
||||
Merge-McpConfig "$env:USERPROFILE\.cursor\mcp.json" $godotWinEntry "Cursor (Godot MCP Pro)" "godot-mcp-pro"
|
||||
$windsurfDir2 = if (Test-Path "$env:APPDATA\Windsurf") { "$env:APPDATA\Windsurf" } else { "$env:USERPROFILE\.codeium\windsurf" }
|
||||
Merge-McpConfig "$windsurfDir2\mcp_config.json" $godotWinEntry "Windsurf (Godot MCP Pro)" "godot-mcp-pro"
|
||||
Merge-McpConfig "$env:APPDATA\Code\User\mcp.json" $godotWinEntry "VS Code (Godot MCP Pro)" "godot-mcp-pro"
|
||||
Write-OK "Godot MCP Pro (Windows) 就绪: $GodotMcpWinDir"
|
||||
} else {
|
||||
$GodotMcpWinDir = ""
|
||||
Write-Warn "未找到 $GodotMcpVersion\server\,跳过 Godot MCP Pro Windows 侧安装"
|
||||
Write-Warn "请确认 $GodotMcpVersion/ 目录与 deploy.ps1 位于同一目录"
|
||||
}
|
||||
|
||||
# ── 5d-ii. WSL2 侧:复制 server/ 到 ~/.mcp-servers/godot-mcp-pro/ ────────────
|
||||
Write-Info "安装 Godot MCP Pro (WSL2)..."
|
||||
$scriptDirFwd = $ScriptDir -replace "\\", "/"
|
||||
$godotWslSrcBase = (Invoke-WSL "wslpath '$scriptDirFwd/$GodotMcpVersion/server'" -IgnoreError).Trim()
|
||||
$godotWslDest = "$wslHome/.mcp-servers/godot-mcp-pro"
|
||||
$godotWslScript = "$godotWslDest/build/index.js"
|
||||
|
||||
$installGodotWslCmd = @"
|
||||
export NVM_DIR="`$HOME/.nvm"
|
||||
[ -s "`$NVM_DIR/nvm.sh" ] && . "`$NVM_DIR/nvm.sh"
|
||||
GODOT_SRC="$godotWslSrcBase"
|
||||
GODOT_DST="$godotWslDest"
|
||||
if [ ! -d "`$GODOT_SRC" ]; then echo "GODOT_SRC_MISSING: `$GODOT_SRC"; exit 0; fi
|
||||
mkdir -p "`$GODOT_DST"
|
||||
if command -v rsync >/dev/null 2>&1; then
|
||||
rsync -a --delete --exclude='node_modules' "`$GODOT_SRC/" "`$GODOT_DST/"
|
||||
else
|
||||
find "`$GODOT_SRC" -mindepth 1 -maxdepth 1 ! -name 'node_modules' -exec cp -r {} "`$GODOT_DST/" \;
|
||||
fi
|
||||
cd "`$GODOT_DST"
|
||||
node build/setup.js install
|
||||
echo GODOT_WSL_OK
|
||||
true
|
||||
"@
|
||||
|
||||
$godotWslResult = Invoke-WSL $installGodotWslCmd -IgnoreError
|
||||
if ($godotWslResult -match "GODOT_WSL_OK") {
|
||||
Write-OK "Godot MCP Pro (WSL2) 就绪: $godotWslScript"
|
||||
$godotWslMcpCmd = @"
|
||||
export NVM_DIR="`$HOME/.nvm"
|
||||
[ -s "`$NVM_DIR/nvm.sh" ] && . "`$NVM_DIR/nvm.sh"
|
||||
claude mcp remove godot-mcp-pro --scope user 2>/dev/null || true
|
||||
claude mcp add --scope user godot-mcp-pro node $godotWslScript
|
||||
echo "Godot MCP Pro Claude Code configured"
|
||||
true
|
||||
"@
|
||||
Invoke-WSL $godotWslMcpCmd -IgnoreError | Out-Null
|
||||
Write-OK "Claude Code CLI (WSL2) MCP -> godot-mcp-pro (node $godotWslScript)"
|
||||
} elseif ($godotWslResult -match "GODOT_SRC_MISSING") {
|
||||
Write-Warn "WSL2 无法访问源目录,跳过 WSL2 侧 Godot MCP Pro 安装"
|
||||
$godotWslScript = ""
|
||||
} else {
|
||||
Write-Warn "Godot MCP Pro WSL2 安装异常,跳过"
|
||||
$godotWslScript = ""
|
||||
}
|
||||
|
||||
# ════════════════════════════════════════════════════════════# Step 6: Windows 防火墙放行 MCP Bridge 端口
|
||||
# ══════════════════════════════════════════════════════════════
|
||||
Write-Step "6/8 Windows 防火墙规则"
|
||||
|
||||
@@ -723,6 +1001,7 @@ $profileBlock = @"
|
||||
$(if ($ANTHROPIC_API_KEY) { "`$env:ANTHROPIC_API_KEY = `"$ANTHROPIC_API_KEY`"" } else { "# ANTHROPIC_API_KEY= (配置 .env 后重新运行)" })
|
||||
`$env:CLAUDE_MODEL = "$CLAUDE_MODEL"
|
||||
function claude-wsl { wsl -d $WSL_DISTRO -- bash -ic 'claude' }
|
||||
function gh-copilot-wsl { wsl -d $WSL_DISTRO -- gh copilot @args }
|
||||
function unity-mcp-status { Invoke-RestMethod http://127.0.0.1:$BridgePort/api/ping -ErrorAction SilentlyContinue }
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
"@
|
||||
@@ -754,9 +1033,12 @@ $items = @(
|
||||
@("Node.js (Win)", (& node --version 2>$null)),
|
||||
@("Node.js (WSL)", $(if ($nodeVer -match "v\d+") { $nodeVer.Trim() } else { "" })),
|
||||
@("Claude Code", $(if ($claudeVer -notmatch "MISSING") { $claudeVer.Trim() } else { "" })),
|
||||
@("GitHub CLI", $(if ($ghVer -notmatch "MISSING") { $ghVer.Trim() } else { "" })),
|
||||
@("Copilot CLI", $(if ($ghCopilotInstalled.Trim() -eq "0") { "gh extension github/gh-copilot" } else { "" })),
|
||||
@("Rust", (Invoke-WSL ". ~/.cargo/env && rustc --version 2>/dev/null" -IgnoreError).Trim()),
|
||||
@("rtk", (Invoke-WSL ". ~/.cargo/env && rtk --version 2>/dev/null" -IgnoreError).Trim()),
|
||||
@("MCP Server", $InstallDir),
|
||||
@("Unity MCP", $InstallDir),
|
||||
@("Godot MCP Pro", $(if ($GodotMcpWinDir) { $GodotMcpWinDir } else { "(未安装)" })),
|
||||
@("Bridge Port", "TCP $BridgePort (防火墙已放行 $BridgePort-$($BridgePort+9))")
|
||||
)
|
||||
foreach ($it in $items) {
|
||||
@@ -778,6 +1060,15 @@ Write-Host ""
|
||||
Write-Host " 4) 在 Claude Code (WSL2) 中使用:" -ForegroundColor White
|
||||
Write-Host " claude-wsl → claude → /mcp" -ForegroundColor DarkGray
|
||||
Write-Host ""
|
||||
Write-Host " 5) 在 WSL2 中使用 GitHub Copilot CLI:" -ForegroundColor White
|
||||
Write-Host " 先执行 gh auth login,然后使用 gh-copilot-wsl suggest \"your prompt\"" -ForegroundColor DarkGray
|
||||
Write-Host ""
|
||||
Write-Host " 6) 在 Godot 项目中启用 MCP Pro 插件(每个项目一次):" -ForegroundColor White
|
||||
Write-Host " 复制 addons/godot_mcp/ 到 Godot 项目根目录" -ForegroundColor DarkGray
|
||||
Write-Host " 在 Project Settings → Plugins 中启用 Godot MCP Pro" -ForegroundColor DarkGray
|
||||
Write-Host " 插件源目录: $GodotMcpSrcDir\addons\godot_mcp\" -ForegroundColor Yellow
|
||||
Write-Host " 启用后 Godot 将在 6505-6509 端口监听 MCP 连接" -ForegroundColor DarkGray
|
||||
Write-Host ""
|
||||
if (-not $ANTHROPIC_API_KEY -and -not $ANTHROPIC_AUTH_TOKEN) {
|
||||
Write-Warn " ⚠ 未设置 API Key,请编辑 .env 后重新运行"
|
||||
Write-Warn " 灵眸用户:填写 ANTHROPIC_AUTH_TOKEN=sk-xxx"
|
||||
|
||||
Reference in New Issue
Block a user