{"record":{"id":"02172741a5fd2820","repo":"googleapis/mcp-toolbox","slug":"unable-to-initialize-configs-w","errorCode":null,"errorMessage":"unable to initialize configs: %w","messagePattern":"unable to initialize configs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/server/server.go","lineNumber":470,"sourceCode":"\t// logging\n\tlogLevel, err := log.SeverityToLevel(cfg.LogLevel.String())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to initialize http log: %w\", err)\n\t}\n\n\tschema := *httplog.SchemaGCP\n\tschema.Level = cfg.LogLevel.String()\n\tschema.Concise(true)\n\thttpOpts := &httplog.Options{\n\t\tLevel:  logLevel,\n\t\tSchema: &schema,\n\t}\n\tlogger := l.SlogLogger()\n\tr.Use(httplog.RequestLogger(logger, httpOpts))\n\n\tsourcesMap, authServicesMap, embeddingModelsMap, toolsMap, promptsMap, groupsMap, err := InitializeConfigs(ctx, cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to initialize configs: %w\", err)\n\t}\n\n\taddr := net.JoinHostPort(cfg.Address, strconv.Itoa(cfg.Port))\n\tsrv := &http.Server{Addr: addr, Handler: r}\n\n\tsseManager := newSseManager(ctx)\n\n\tprimitiveManager := primitives.NewPrimitiveManager(sourcesMap, authServicesMap, embeddingModelsMap, toolsMap, promptsMap, groupsMap)\n\n\tlimit := cfg.HttpMaxRequestBytes\n\tif limit <= 0 {\n\t\tlimit = DefaultHTTPMaxRequestBytes\n\t}\n\n\tmcp.InitializeProtocols(mcp.ProtocolOptions{\n\t\tDisableExt: cfg.DisableExt,\n\t})\n","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/server/server.go#L452-L488","documentation":"NewServer delegates all config initialization (sources, auth services, embedding models, tools, prompts, groups) to InitializeConfigs. Any failure inside that pipeline is wrapped once here, so the root cause (e.g. a DB connection failure or a tool config error) is chained via %w and should be read from the wrapped error.","triggerScenarios":"Running `toolbox serve` (or tests calling NewServer) where InitializeConfigs fails for any reason: unreachable database URI, failed auth service setup, tool/prompt/group initialization errors, or embedding model misconfiguration.","commonSituations":"Wrong connection strings or expired credentials, database host unreachable from the container, invalid YAML schema after upgrade, or missing required fields in sources section.","solutions":["Read the innermost wrapped error (use `%+v` or errors.Unwrap chains) to find the real failure.","Verify each source's URI/credentials by connecting manually (psql/mysql client, gcloud auth) before starting the toolbox.","Validate the tools.yml structure against the docs for your toolbox version.","If a source is intentionally unreachable at boot, consider lazy initialization or removing it temporarily to isolate."],"exampleFix":"// before\nsources:\n  pg:\n    kind: postgres\n    uri: postgres://user:pass@wrong-host:5432/db\n\n// after\nsources:\n  pg:\n    kind: postgres\n    uri: postgres://user:pass@localhost:5432/db?sslmode=disable","handlingStrategy":"try-catch","validationCode":"// Pre-flight: verify each source connects before starting the server\nfor name, sc := range cfg.Sources {\n    if err := sc.Initialize(ctx); err != nil {\n        return fmt.Errorf(\"source %q unreachable: %w\", name, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"srv, err := server.NewServer(ctx, cfg)\nif err != nil {\n    log.Errorf(\"config init failed: %+v\", err) // print full unwrap chain\n    var inner error\n    for e := err; e != nil; e = errors.Unwrap(e) {\n        inner = e\n    }\n    log.Errorf(\"root cause: %v\", inner)\n    return err\n}","preventionTips":["Test DB connectivity/credentials from the same host/network before launch.","Use secrets managers instead of hardcoded URIs; rotate before expiry.","CI-validate tools.yml (sources, tools, groups) on every change.","Keep config schema aligned with the deployed toolbox version."],"tags":["go","startup","configuration","initialization"],"backgroundTag":"config-initialization-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}