{"record":{"id":"f1126d94682bfeb6","repo":"flipped-aurora/gin-vue-admin","slug":"mcp-w","errorCode":null,"errorMessage":"读取 MCP 配置失败: %w","messagePattern":"读取 MCP 配置失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/cmd/mcp/config.go","lineNumber":31,"sourceCode":"\t\"github.com/flipped-aurora/gin-vue-admin/server/config\"\n\t\"github.com/flipped-aurora/gin-vue-admin/server/global\"\n\t\"gopkg.in/yaml.v3\"\n)\n\ntype standaloneConfig struct {\n\tMCP      config.MCP      `yaml:\"mcp\"`\n\tAutoCode config.Autocode `yaml:\"autocode\"`\n}\n\nfunc loadStandaloneConfig() (string, error) {\n\tconfigPath, err := resolveConfigPath()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tcontent, err := os.ReadFile(configPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"读取 MCP 配置失败: %w\", err)\n\t}\n\n\tvar cfg standaloneConfig\n\tif err := yaml.Unmarshal(content, &cfg); err != nil {\n\t\treturn \"\", fmt.Errorf(\"解析 MCP 配置失败: %w\", err)\n\t}\n\n\tapplyStandaloneDefaults(configPath, &cfg)\n\n\tglobal.GVA_CONFIG.MCP = cfg.MCP\n\tglobal.GVA_CONFIG.AutoCode = cfg.AutoCode\n\n\treturn configPath, nil\n}\n\nfunc resolveConfigPath() (string, error) {\n\texplicit, err := parseConfigFlag(os.Args[1:])\n\tif err != nil {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/cmd/mcp/config.go#L13-L49","documentation":"The standalone MCP server loads its YAML config before starting. This error wraps os.ReadFile failure when the config file path cannot be read (missing file, permission denied, path is a directory).","triggerScenarios":"Running the MCP server when the config file doesn't exist at the resolved path, the process lacks read permission, or the path points to a directory.","commonSituations":"Wrong working directory so a relative config path resolves incorrectly; config never created; file permissions changed; typo'd --config flag value.","solutions":["Check the resolved path exists: ls -l <configPath> (the error includes the wrapped os error)","Run the server from the directory where the config lives, or pass the absolute path via the config flag","Fix file permissions so the process user can read the file","Create the config file from the project's example config if missing"],"exampleFix":"// before\n./mcp-server   # expects config.yaml in cwd\n// after\n./mcp-server --config /absolute/path/to/config.yaml","handlingStrategy":"validation","validationCode":"info, err := os.Stat(configPath)\nif err != nil { log.Fatalf(\"config missing: %v\", err) }\nif info.IsDir() { log.Fatalf(\"config path is a directory: %s\", configPath) }","typeGuard":null,"tryCatchPattern":"cfg, err := loadStandaloneConfig(path)\nif err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) { fmt.Printf(\"cannot read %s: %v\\n\", pe.Path, pe.Err) }\n    os.Exit(1)\n}","preventionTips":["Use absolute config paths or resolve relative to the binary","Add a pre-start check in the entry script/systemd unit","Ship an example config and fail fast with a helpful message"],"tags":["config","file-io","yaml","startup"],"backgroundTag":"config-file-not-found","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}