Files
MyGoNavi/tools/claude-gonavi-mcp.ps1
Syngnat 5b843ee25b feat(ai-mcp): 完善外部客户端安装链路并收紧 SQL 安全控制
- 新增 GoNavi MCP stdio server 与 Claude/Codex 用户级安装入口

- 增加安装状态检测、刷新复制能力和浏览器联调 mock

- 外部 execute_sql 对齐 GoNavi safetyLevel 并补充前端/后端验证
2026-06-07 20:27:50 +08:00

45 lines
1.2 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
param(
[switch]$SkipBuild
)
$ErrorActionPreference = 'Stop'
$ClaudeArgs = $args
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$binDir = Join-Path $repoRoot 'bin'
$serverExe = Join-Path $binDir 'gonavi-mcp-server.exe'
if (-not $SkipBuild) {
if (-not (Test-Path $binDir)) {
New-Item -ItemType Directory -Path $binDir | Out-Null
}
& go build -o $serverExe .\cmd\gonavi-mcp-server
if ($LASTEXITCODE -ne 0) {
throw "构建 gonavi-mcp-server 失败"
}
} elseif (-not (Test-Path $serverExe)) {
throw "未找到已编译的 gonavi-mcp-server.exe请去掉 -SkipBuild 或先手动构建"
}
$mcpConfig = @{
mcpServers = @{
gonavi = @{
type = 'stdio'
command = $serverExe
args = @()
env = @{}
}
}
} | ConvertTo-Json -Compress -Depth 6
$tempConfig = Join-Path ([System.IO.Path]::GetTempPath()) ("gonavi-claude-mcp-" + [System.Guid]::NewGuid().ToString("N") + ".json")
try {
Set-Content -LiteralPath $tempConfig -Value $mcpConfig -Encoding UTF8
& claude @ClaudeArgs --mcp-config $tempConfig --strict-mcp-config
exit $LASTEXITCODE
} finally {
Remove-Item -LiteralPath $tempConfig -ErrorAction SilentlyContinue
}