{"record":{"id":"470e53ff90c02dd6","repo":"flipped-aurora/gin-vue-admin","slug":"panic-err-standalone-mcp-config-load-failed","errorCode":null,"errorMessage":"panic(err) — standalone MCP config load failed","messagePattern":"panic\\(err\\) — standalone MCP config load failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/cmd/mcp/main.go","lineNumber":15,"sourceCode":"package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/flipped-aurora/gin-vue-admin/server/global\"\n\tmcpTool \"github.com/flipped-aurora/gin-vue-admin/server/mcp\"\n\t\"github.com/flipped-aurora/gin-vue-admin/server/utils/logger\"\n\t_ \"go.uber.org/automaxprocs\"\n)\n\nfunc main() {\n\tconfigPath, err := loadStandaloneConfig()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err := initializeStandaloneLogger(); err != nil {\n\t\tpanic(err)\n\t}\n\n\taddr := fmt.Sprintf(\":%d\", global.GVA_CONFIG.MCP.Addr)\n\tserver := mcpTool.NewStreamableHTTPServer()\n\n\tlogger.Bg().Mod(\"cli\").\n\t\tField(\"config\", configPath).\n\t\tField(\"addr\", addr).\n\t\tField(\"path\", global.GVA_CONFIG.MCP.Path).\n\t\tField(\"upstream\", global.GVA_CONFIG.MCP.UpstreamBaseURL).\n\t\tInfo(\"mcp独立服务启动\")\n\n\tif err := server.Start(addr); err != nil {\n\t\tlogger.Bg().Mod(\"cli\").Err(err).Error(\"mcp独立服务启动失败\")","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/cmd/mcp/main.go#L1-L33","documentation":"The standalone MCP server binary panics at startup when loadStandaloneConfig cannot load or parse the MCP configuration (missing config file, invalid YAML, or missing required fields). panic(err) is used deliberately so the process aborts loudly instead of running with a bad config.","triggerScenarios":"Running `go run ./cmd/mcp` or the built mcp binary with a missing/misplaced config file, wrong config path flag/env, or a config that fails validation inside loadStandaloneConfig.","commonSituations":"Deploying the mcp binary without copying the config; running from a different working directory than expected; YAML syntax error after hand-editing; renaming config keys after an upgrade.","solutions":["Confirm the config file exists at the path loadStandaloneConfig resolves (check working directory and any -c/env path)","Validate the YAML syntax (yamllint) and required MCP fields (addr, path, upstream)","Run the binary from the project root or pass an explicit absolute config path","Compare against the repo's example config for missing keys"],"exampleFix":"// before\n./mcp-server   # run from / with no config\n// after\ncd /opt/gva && ./mcp-server --config /opt/gva/config.yaml","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(configPath); err != nil { log.Fatalf(\"MCP config not found at %s: %v\", configPath, err) }","typeGuard":null,"tryCatchPattern":"// in a wrapper\nfunc run() (err error) { defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"mcp startup panic: %v\", r) } }(); /* start server */; return nil }","preventionTips":["Ship an example config and validate it in CI (yamllint + field checks)","Use an absolute config path or resolve relative to the executable","Document required working directory for the mcp binary","Fail fast in a wrapper script that checks the config exists before exec"],"tags":["config","startup","panic","mcp"],"backgroundTag":"missing-config-file","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}