flipped-aurora/gin-vue-admin · error
未找到 server 根目录,无法启动 MCP 独立服务
Error message
未找到 server 根目录,无法启动 MCP 独立服务
What it means
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.
Source
Thrown at server/mcp/standalone_manager.go:296
return GetManagedStandaloneStatus(context.Background()), ctx.Err()
case <-deadline.C:
return GetManagedStandaloneStatus(context.Background()), fmt.Errorf("等待 MCP 独立服务启动超时,请查看日志: %s", meta.LogPath)
case <-ticker.C:
current := GetManagedStandaloneStatus(context.Background())
if current.Reachable {
return current, nil
}
if meta.PID > 0 && !processExists(meta.PID) {
return current, fmt.Errorf("MCP 独立进程已退出,请查看日志: %s", meta.LogPath)
}
}
}
}
func resolveManagedStartCommand() (string, []string, string, string, error) {
serverRoot := resolveMCPServerRoot()
if serverRoot == "" {
return "", nil, "", "", errors.New("未找到 server 根目录,无法启动 MCP 独立服务")
}
configPath, err := resolveMCPConfigPath(serverRoot)
if err != nil {
return "", nil, "", "", err
}
if explicit := strings.TrimSpace(os.Getenv("GVA_MCP_BIN")); explicit != "" {
if !fileExists(explicit) {
return "", nil, "", "", fmt.Errorf("GVA_MCP_BIN 指向的文件不存在: %s", explicit)
}
return explicit, []string{"-config", configPath}, filepath.Dir(explicit), configPath, nil
}
binaryPath, err := ensureManagedBinary(serverRoot)
if err != nil {
return "", nil, "", "", err
}View on GitHub (pinned to 3136500ef3)
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
Example fix
# before (config.yaml) autocode: root: "" server: "" # after autocode: root: "/opt/gin-vue-admin" server: "/opt/gin-vue-admin/server"
Defensive patterns
Strategy: validation
Validate before calling
cfg := global.GVA_CONFIG.AutoCode
if strings.TrimSpace(cfg.Root) == "" || strings.TrimSpace(cfg.Server) == "" {
return errors.New("set autocode.root and autocode.server in config.yaml before starting managed MCP")
} Try / catch
if _, _, _, _, err := resolveManagedStartCommand(); err != nil && strings.Contains(err.Error(), "server 根目录") {
log.Fatalf("fix autocode config paths: %v", err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- 当前 MCP 服务不是由页面启动的,无法自动停用
- 未找到 MCP 配置文件,请确认 cmd/mcp/config.yaml 或 server/config.yaml 存在
- GVA_MCP_BIN 指向的文件不存在: %s
- 未找到 MCP 独立配置文件,请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG
- 未能自动识别项目根目录,请在 MCP 配置中设置 autocode.root
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/441a355c1e1e2392.
Report an issue: GitHub.