{"record":{"id":"441a355c1e1e2392","repo":"flipped-aurora/gin-vue-admin","slug":"server-mcp","errorCode":null,"errorMessage":"未找到 server 根目录，无法启动 MCP 独立服务","messagePattern":"未找到 server 根目录，无法启动 MCP 独立服务","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/standalone_manager.go","lineNumber":296,"sourceCode":"\t\t\treturn GetManagedStandaloneStatus(context.Background()), ctx.Err()\n\t\tcase <-deadline.C:\n\t\t\treturn GetManagedStandaloneStatus(context.Background()), fmt.Errorf(\"等待 MCP 独立服务启动超时，请查看日志: %s\", meta.LogPath)\n\t\tcase <-ticker.C:\n\t\t\tcurrent := GetManagedStandaloneStatus(context.Background())\n\t\t\tif current.Reachable {\n\t\t\t\treturn current, nil\n\t\t\t}\n\t\t\tif meta.PID > 0 && !processExists(meta.PID) {\n\t\t\t\treturn current, fmt.Errorf(\"MCP 独立进程已退出，请查看日志: %s\", meta.LogPath)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc resolveManagedStartCommand() (string, []string, string, string, error) {\n\tserverRoot := resolveMCPServerRoot()\n\tif serverRoot == \"\" {\n\t\treturn \"\", nil, \"\", \"\", errors.New(\"未找到 server 根目录，无法启动 MCP 独立服务\")\n\t}\n\n\tconfigPath, err := resolveMCPConfigPath(serverRoot)\n\tif err != nil {\n\t\treturn \"\", nil, \"\", \"\", err\n\t}\n\n\tif explicit := strings.TrimSpace(os.Getenv(\"GVA_MCP_BIN\")); explicit != \"\" {\n\t\tif !fileExists(explicit) {\n\t\t\treturn \"\", nil, \"\", \"\", fmt.Errorf(\"GVA_MCP_BIN 指向的文件不存在: %s\", explicit)\n\t\t}\n\t\treturn explicit, []string{\"-config\", configPath}, filepath.Dir(explicit), configPath, nil\n\t}\n\n\tbinaryPath, err := ensureManagedBinary(serverRoot)\n\tif err != nil {\n\t\treturn \"\", nil, \"\", \"\", err\n\t}","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/standalone_manager.go#L278-L314","documentation":"resolveManagedStartCommand locates the server root directory (via resolveMCPServerRoot, derived from AutoCode.Root / AutoCode.Server config and heuristics) before launching the MCP standalone service. It throws this error when no server root can be resolved, because the config file and `go run` working directory both depend on it. Without a server root the managed start cannot proceed.","triggerScenarios":"Calling StartManagedStandalone when global.GVA_CONFIG.AutoCode.Root and AutoCode.Server are empty/whitespace and the default heuristics (binary location, working directory) fail to locate the `server` directory.","commonSituations":"Fresh deployment where config.yaml lacks autocode root/server paths; running the backend binary from an unexpected working directory so relative resolution fails; renamed or non-standard project layout without a `server` folder.","solutions":["Set autocode.root / autocode.server in config.yaml to the absolute server directory path","Run the backend from the project root so directory heuristics can find `server/`","Verify the deployed layout actually contains the server root directory the config points to","If config is auto-generated, re-generate or re-sync config.yaml after moving the project"],"exampleFix":"# before (config.yaml)\nautocode:\n  root: \"\"\n  server: \"\"\n# after\nautocode:\n  root: \"/opt/gin-vue-admin\"\n  server: \"/opt/gin-vue-admin/server\"","handlingStrategy":"validation","validationCode":"cfg := global.GVA_CONFIG.AutoCode\nif strings.TrimSpace(cfg.Root) == \"\" || strings.TrimSpace(cfg.Server) == \"\" {\n    return errors.New(\"set autocode.root and autocode.server in config.yaml before starting managed MCP\")\n}","typeGuard":null,"tryCatchPattern":"if _, _, _, _, err := resolveManagedStartCommand(); err != nil && strings.Contains(err.Error(), \"server 根目录\") {\n    log.Fatalf(\"fix autocode config paths: %v\", err)\n}","preventionTips":["Set autocode.root and autocode.server to absolute paths in every environment's config.yaml","Keep the deployment layout containing `server/` intact","Start the backend from the project root so path heuristics work as fallback"],"tags":["mcp","configuration","golang"],"backgroundTag":"missing-config-path","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}