{"record":{"id":"fc6989a79404d29d","repo":"flipped-aurora/gin-vue-admin","slug":"panic-err-mcp","errorCode":null,"errorMessage":"panic(err) — mcp独立服务启动失败","messagePattern":"panic\\(err\\) — mcp独立服务启动失败","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/cmd/mcp/main.go","lineNumber":34,"sourceCode":"\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独立服务启动失败\")\n\t\tpanic(err)\n\t}\n}\n","sourceCodeStart":16,"sourceCodeEnd":37,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/cmd/mcp/main.go#L16-L37","documentation":"The standalone MCP HTTP server failed to bind/listen on the configured address; the code logs 'mcp独立服务启动失败' and then panics so the process exits rather than silently running without a server. server.Start returns the underlying net/http error which is both logged and re-panicked.","triggerScenarios":"server.Start(addr) fails because the port from GVA_CONFIG.MCP.Addr is already in use, the address is invalid, or the process lacks permission to bind (ports <1024 as non-root).","commonSituations":"Another instance of the service still running (port conflict); systemd/supervisord double-start; port 80/443 chosen without root capability; config Addr malformed (missing colon or non-numeric port).","solutions":["Find and stop the process holding the port: lsof -i :PORT or ss -ltnp, or change MCP.Addr to a free port","Fix the Addr format in config (e.g. \":8888\")","Use a non-privileged port or grant the capability (setcap cap_net_bind_service) for ports <1024","Restart the service after resolving"],"exampleFix":"// before\nmcp:\n  addr: \":8888\"   # already in use\n// after\nmcp:\n  addr: \":8889\"","handlingStrategy":"retry","validationCode":"ln, err := net.Listen(\"tcp\", addr); if err != nil { log.Fatalf(\"port %s unavailable: %v\", addr, err) }; ln.Close()","typeGuard":null,"tryCatchPattern":"if err := server.Start(addr); err != nil { logger.Bg().Mod(\"cli\").Err(err).Error(\"mcp独立服务启动失败\"); time.Sleep(retryBackoff); /* retry N times or exit */ panic(err) }","preventionTips":["Use SO_REUSEPORT or a port allocation range instead of a fixed port","Run a pre-start check (ss -ltn) in deployment scripts to catch port conflicts","Avoid single-instance managers double-starting the service (systemd ensures one instance)","Use ports >1024 or grant capabilities when binding privileged ports"],"tags":["network","port-conflict","startup","mcp"],"backgroundTag":"address-already-in-use","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}