{"record":{"id":"99fe56c5cbd94320","repo":"flipped-aurora/gin-vue-admin","slug":"go-mcp","errorCode":null,"errorMessage":"未检测到可用的 Go 环境，且本地没有可复用的 MCP 独立二进制","messagePattern":"未检测到可用的 Go 环境，且本地没有可复用的 MCP 独立二进制","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/standalone_manager.go","lineNumber":350,"sourceCode":"\n\t\tcmd := exec.CommandContext(buildCtx, goBin, \"build\", \"-o\", binaryPath, \"./cmd/mcp\")\n\t\tcmd.Dir = serverRoot\n\t\toutput, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\tmessage := strings.TrimSpace(string(output))\n\t\t\tif message != \"\" {\n\t\t\t\treturn \"\", fmt.Errorf(\"构建 MCP 独立服务失败: %w, 输出: %s\", err, message)\n\t\t\t}\n\t\t\treturn \"\", fmt.Errorf(\"构建 MCP 独立服务失败: %w\", err)\n\t\t}\n\t\treturn binaryPath, nil\n\t}\n\n\tif fileExists(binaryPath) {\n\t\treturn binaryPath, nil\n\t}\n\n\treturn \"\", errors.New(\"未检测到可用的 Go 环境，且本地没有可复用的 MCP 独立二进制\")\n}\n\nfunc resolveMCPServerRoot() string {\n\troot := strings.TrimSpace(global.GVA_CONFIG.AutoCode.Root)\n\tserverDir := strings.TrimSpace(global.GVA_CONFIG.AutoCode.Server)\n\tif serverDir == \"\" {\n\t\tserverDir = \"server\"\n\t}\n\n\tcandidates := []string{}\n\tif root != \"\" {\n\t\tcandidates = append(candidates, filepath.Join(root, filepath.FromSlash(serverDir)))\n\t\tcandidates = append(candidates, root)\n\t}\n\n\tif cwd, err := os.Getwd(); err == nil {\n\t\tcandidates = append(candidates, cwd)\n\t\tcandidates = append(candidates, filepath.Join(cwd, \"server\"))","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/standalone_manager.go#L332-L368","documentation":"ensureManagedBinary guarantees a runnable MCP standalone binary: it first tries building with the local Go toolchain, and otherwise falls back to an existing prebuilt binary at binaryPath. This error is thrown when BOTH are unavailable — no `go` command on PATH AND no previously built binary exists — so the managed start has no way to produce a runnable MCP process.","triggerScenarios":"StartManagedStandalone on a machine where the Go toolchain is not installed or not on PATH, and the mcp runtime directory contains no previously compiled standalone binary.","commonSituations":"Deploying to a slim production image without Go; running the page in Docker where PATH lacks go; first-time start on a new machine; cleaned runtime directory removing the cached binary.","solutions":["Install Go and ensure `go` is on PATH (go version should succeed for the backend process user)","Build the MCP standalone binary once on a machine with Go and copy it to the expected runtime binaryPath","Fix PATH in the backend service environment (systemd Environment= / Dockerfile ENV) so `go` is discoverable","Re-check after cleaning the runtime dir: without Go the binary will never be rebuilt"],"exampleFix":"# before: no go toolchain\ngo version  # command not found\n# after\n# Debian/Ubuntu\napt-get install -y golang-go\n# or use official tarball\nwget https://go.dev/dl/go1.22.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.22.linux-amd64.tar.gz\nexport PATH=$PATH:/usr/local/go/bin","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"go\"); err != nil {\n    return errors.New(\"go toolchain required to build MCP standalone binary (or prebuild it into the runtime dir)\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := ensureManagedBinary(); err != nil {\n    log.Fatalf(\"MCP binary unavailable: %v — install Go or ship a prebuilt binary\", err)\n}","preventionTips":["Install Go in every environment that starts the managed MCP service","Fix PATH for the backend service user (systemd/Docker ENV)","Build the binary once on a Go machine and copy it to the expected runtime binaryPath for toolchain-less hosts"],"tags":["mcp","environment","go-toolchain"],"backgroundTag":"missing-go-toolchain","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}