googleapis/mcp-toolbox · error

unable to initialize configs: %w

Error message

unable to initialize configs: %w

What it means

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.

Source

Thrown at internal/server/server.go:470

	// logging
	logLevel, err := log.SeverityToLevel(cfg.LogLevel.String())
	if err != nil {
		return nil, fmt.Errorf("unable to initialize http log: %w", err)
	}

	schema := *httplog.SchemaGCP
	schema.Level = cfg.LogLevel.String()
	schema.Concise(true)
	httpOpts := &httplog.Options{
		Level:  logLevel,
		Schema: &schema,
	}
	logger := l.SlogLogger()
	r.Use(httplog.RequestLogger(logger, httpOpts))

	sourcesMap, authServicesMap, embeddingModelsMap, toolsMap, promptsMap, groupsMap, err := InitializeConfigs(ctx, cfg)
	if err != nil {
		return nil, fmt.Errorf("unable to initialize configs: %w", err)
	}

	addr := net.JoinHostPort(cfg.Address, strconv.Itoa(cfg.Port))
	srv := &http.Server{Addr: addr, Handler: r}

	sseManager := newSseManager(ctx)

	primitiveManager := primitives.NewPrimitiveManager(sourcesMap, authServicesMap, embeddingModelsMap, toolsMap, promptsMap, groupsMap)

	limit := cfg.HttpMaxRequestBytes
	if limit <= 0 {
		limit = DefaultHTTPMaxRequestBytes
	}

	mcp.InitializeProtocols(mcp.ProtocolOptions{
		DisableExt: cfg.DisableExt,
	})

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Read the innermost wrapped error (use `%+v` or errors.Unwrap chains) to find the real failure.
  2. Verify each source's URI/credentials by connecting manually (psql/mysql client, gcloud auth) before starting the toolbox.
  3. Validate the tools.yml structure against the docs for your toolbox version.
  4. If a source is intentionally unreachable at boot, consider lazy initialization or removing it temporarily to isolate.

Example fix

// before
sources:
  pg:
    kind: postgres
    uri: postgres://user:pass@wrong-host:5432/db

// after
sources:
  pg:
    kind: postgres
    uri: postgres://user:pass@localhost:5432/db?sslmode=disable
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: verify each source connects before starting the server
for name, sc := range cfg.Sources {
    if err := sc.Initialize(ctx); err != nil {
        return fmt.Errorf("source %q unreachable: %w", name, err)
    }
}

Try / catch

srv, err := server.NewServer(ctx, cfg)
if err != nil {
    log.Errorf("config init failed: %+v", err) // print full unwrap chain
    var inner error
    for e := err; e != nil; e = errors.Unwrap(e) {
        inner = e
    }
    log.Errorf("root cause: %v", inner)
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: Wrong connection strings or expired credentials, database host unreachable from the container, invalid YAML schema after upgrade, or missing required fields in sources section.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/02172741a5fd2820. Report an issue: GitHub.