googleapis/mcp-toolbox · critical

unable to create pool: %w

Error message

unable to create pool: %w

What it means

The alloydbpg source's Initialize builds a pgx connection pool via the AlloyDB Go Connector (initAlloyDBPgConnectionPool). This error wraps any failure while constructing that pool — dialer setup, credential resolution, or initial connection creation during pool warm-up. The source cannot be registered without a working pool.

Source

Thrown at internal/sources/alloydbpg/alloydb_pg.go:74

	Region       string         `yaml:"region" validate:"required"`
	Cluster      string         `yaml:"cluster" validate:"required"`
	Instance     string         `yaml:"instance" validate:"required"`
	IPType       sources.IPType `yaml:"ipType" validate:"required"`
	User         string         `yaml:"user"`
	Password     string         `yaml:"password"`
	Database     string         `yaml:"database" validate:"required"`
	ReadOnly     bool           `yaml:"readOnly"`
	SQLCommenter *bool          `yaml:"sqlCommenter"`
}

func (r Config) SourceConfigType() string {
	return SourceType
}

func (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {
	pool, err := initAlloyDBPgConnectionPool(ctx, tracer, r.Name, r.Project, r.Region, r.Cluster, r.Instance, r.IPType.String(), r.User, r.Password, r.Database, r.ReadOnly)
	if err != nil {
		return nil, fmt.Errorf("unable to create pool: %w", err)
	}

	err = pool.Ping(ctx)
	if err != nil {
		pool.Close()
		if r.ReadOnly &&
			strings.Contains(err.Error(), "unrecognized configuration parameter") &&
			strings.Contains(err.Error(), "alloydb_session_read_only") {
			return nil, fmt.Errorf("failed to initialize AlloyDB source in read-only mode: 'alloydb_session_read_only' is not supported on this instance version. See documentation for details: https://mcp-toolbox.dev/integrations/alloydb/source/#reference: %w", err)
		}
		return nil, fmt.Errorf("unable to connect successfully: %w", err)
	}

	s := &Source{
		Config: r,
		Pool:   pool,
	}
	return s, nil

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Check the wrapped error message for the root cause (DNS, auth, dial timeout).
  2. Verify project, region, cluster, and instance values against `gcloud alloydb instances list`.
  3. Ensure ADC is available: run `gcloud auth application-default login` or set GOOGLE_APPLICATION_CREDENTIALS.
  4. If using private IP, run from a network that can reach the instance; switch ipType to public for testing.
  5. Confirm the database user/password are correct and IAM auth settings match the instance config.

Example fix

// before
source: my-source
  kind: alloydb-postgres
  project: my-proj
  cluster: my-clstr
  instance: my-instc  # typo
// after
source: my-source
  kind: alloydb-postgres
  project: my-proj
  cluster: my-cluster
  instance: my-instance
Defensive patterns

Strategy: validation

Validate before calling

// Validate config + credentials before starting the server
gcloud alloydb instances describe INSTANCE --cluster=CLUSTER --region=REGION --project=PROJECT
gcloud auth application-default print-access-token > /dev/null || echo "ADC not set"
# ensure ipType is one of: public, private, psc

Try / catch

src, err := cfg.Initialize(ctx, tracer)
if err != nil && strings.Contains(err.Error(), "unable to create pool") {
    // check project/cluster/instance names, ADC, and network reachability, then re-init
    return fmt.Errorf("alloydb pool init failed, check config and credentials: %w", err)
}

Prevention

When it happens

Trigger: Config.Initialize with bad project/region/cluster/instance coordinates, missing Application Default Credentials, invalid ipType, unreachable network, or IAM auth misconfiguration passed to initAlloyDBPgConnectionPool.

Common situations: Typo'd cluster/instance names, running outside GCP without GOOGLE_APPLICATION_CREDENTIALS set, VPC/private-IP instances unreachable from the client, or password/user misconfiguration (e.g. password without username — see error 429).

Related errors


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