{"record":{"id":"8a18a76b8c00e731","repo":"flipped-aurora/gin-vue-admin","slug":"mcp-cmd-mcp-config-gva","errorCode":null,"errorMessage":"未找到 MCP 独立配置文件，请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG 指定 config.yaml","messagePattern":"未找到 MCP 独立配置文件，请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG 指定 config\\.yaml","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/mcp/config.go","lineNumber":82,"sourceCode":"\tcandidates := []string{\n\t\tfilepath.Join(wd, \"config.yaml\"),\n\t\tfilepath.Join(wd, \"mcp.yaml\"),\n\t\tfilepath.Join(wd, \"cmd\", \"mcp\", \"config.yaml\"),\n\t\tfilepath.Join(wd, \"server\", \"cmd\", \"mcp\", \"config.yaml\"),\n\t\tfilepath.Join(exeDir, \"config.yaml\"),\n\t\tfilepath.Join(exeDir, \"mcp.yaml\"),\n\t}\n\n\tfor _, candidate := range candidates {\n\t\tif candidate == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif info, err := os.Stat(candidate); err == nil && !info.IsDir() {\n\t\t\treturn filepath.Abs(candidate)\n\t\t}\n\t}\n\n\treturn \"\", errors.New(\"未找到 MCP 独立配置文件，请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG 指定 config.yaml\")\n}\n\nfunc parseConfigFlag(args []string) (string, error) {\n\tfs := flag.NewFlagSet(\"gva-mcp\", flag.ContinueOnError)\n\tfs.SetOutput(io.Discard)\n\n\tvar configPath string\n\tfs.StringVar(&configPath, \"c\", \"\", \"MCP config file path\")\n\tfs.StringVar(&configPath, \"config\", \"\", \"MCP config file path\")\n\tif err := fs.Parse(args); err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn strings.TrimSpace(configPath), nil\n}\n\nfunc applyStandaloneDefaults(configPath string, cfg *standaloneConfig) {\n\tif cfg.MCP.Name == \"\" {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/cmd/mcp/config.go#L64-L100","documentation":"The standalone MCP server's config loader resolves the config file from -config flag, GVA_MCP_CONFIG env var, current dir, then cmd/mcp dir. If no readable config.yaml is found in any candidate location, loadStandaloneConfig fails with this error and the process exits.","triggerScenarios":"Running the gva-mcp binary from a working directory that lacks config.yaml, without -config and without GVA_MCP_CONFIG set, and no config.yaml next to cmd/mcp.","commonSituations":"Launching the binary from PATH or a systemd unit whose WorkingDirectory is wrong; running `go run ./cmd/mcp` from a different package dir; renamed/missing config file in deployment.","solutions":["Pass the config explicitly: ./gva-mcp -config /path/to/config.yaml","Set the GVA_MCP_CONFIG environment variable to the config path","Run the command from the project root or server/cmd/mcp where config.yaml exists","Create a config.yaml in one of the searched locations"],"exampleFix":"// before\n./gva-mcp\n// after\nGVA_MCP_CONFIG=./config.yaml ./gva-mcp\n// or\n./gva-mcp -config /etc/gva/mcp/config.yaml","handlingStrategy":"validation","validationCode":"// shell pre-flight before launching the mcp server\nif [ -z \"$GVA_MCP_CONFIG\" ] && [ ! -f ./config.yaml ] && [ ! -f ./cmd/mcp/config.yaml ]; then\n  echo \"gva-mcp: no config.yaml found; set -config or GVA_MCP_CONFIG\" >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":"cfg, err := loadStandaloneConfig()\nif err != nil {\n  fmt.Fprintf(os.Stderr, \"启动失败: %v\\n\", err)\n  os.Exit(1)\n}","preventionTips":["Always pass -config explicitly in systemd/containers (set WorkingDirectory too)","Set GVA_MCP_CONFIG in the deployment environment as the single source of truth","Document the config search order (flag > env > cwd > cmd/mcp) in the repo README","Verify config.yaml is shipped in the deploy artifact"],"tags":["config","mcp","go","startup"],"backgroundTag":"missing-config-file","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}