flipped-aurora/gin-vue-admin · error
未能自动识别项目根目录,请在 MCP 配置中设置 autocode.root
Error message
未能自动识别项目根目录,请在 MCP 配置中设置 autocode.root
What it means
applyStandaloneDefaults auto-detects the project root by walking upward from the config/binary location looking for a marker (go.mod etc.). If the walk reaches the filesystem root without a match, it errors and asks the user to set autocode.root in the MCP config.
Source
Thrown at server/cmd/mcp/config.go:164
}
func detectProjectRoot(startDir string) (string, error) {
dir := startDir
for {
serverDir := filepath.Join(dir, "server")
webDir := filepath.Join(dir, "web")
if isDir(serverDir) && isDir(webDir) {
return dir, nil
}
parent := filepath.Dir(dir)
if parent == dir {
break
}
dir = parent
}
return "", errors.New("未能自动识别项目根目录,请在 MCP 配置中设置 autocode.root")
}
func detectGoModule(goModPath string) (string, error) {
file, err := os.Open(goModPath)
if err != nil {
return "", err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if strings.HasPrefix(line, "module ") {
return strings.TrimSpace(strings.TrimPrefix(line, "module ")), nil
}
}
if err := scanner.Err(); err != nil {View on GitHub (pinned to 3136500ef3)
Solutions
- Set autocode.root: /absolute/path/to/project in the MCP config.yaml
- Run the mcp server from within the project directory so detection finds the marker
- Ensure go.mod (or the marker it looks for) exists at the project root
Example fix
# mcp config.yaml # before autocode: # root not set # after autocode: root: /home/user/projects/gin-vue-admin/server
Defensive patterns
Strategy: validation
Validate before calling
# before launch, verify autocode.root resolves to a dir containing go.mod
ROOT=$(yq '.autocode.root' config.yaml)
[ -f "$ROOT/go.mod" ] || { echo "autocode.root ($ROOT) missing go.mod" >&2; exit 1; } Try / catch
root, err := detectProjectRoot(startDir)
if err != nil {
return fmt.Errorf("resolve project root: %w (set autocode.root to skip detection)", err)
} Prevention
- Explicitly set autocode.root in config.yaml for all non-dev deployments
- Keep go.mod at the repo root so upward detection works
- Log the directories walked during detection to speed up diagnosis
- Avoid launching the binary from /, /tmp, or other marker-less dirs
When it happens
Trigger: No autocode.root configured and no ancestor directory of the working directory contains the root marker (e.g. config placed in an isolated dir, or running outside a checkout).
Common situations: Deploying the mcp binary into a bare directory without the repo; project root detection depending on go.mod but repo checked out without it; symlinked/overlay paths confusing the upward walk.
Related errors
- 未找到 MCP 独立配置文件,请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG
- go.mod 中未找到 module 定义
- panic(err) — standalone MCP config load failed
- 参数错误:executionPlan 必须提供
- packageName 不能为空
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/1e6f97a6a0c4ee7b.
Report an issue: GitHub.