googleapis/mcp-toolbox · critical
unable to create pool: %w
Error message
unable to create pool: %w
What it means
This error is returned by the cloud-sql-mysql source's Initialize when initCloudSQLMySQLConnectionPool fails to build the MySQL connection pool. It wraps earlier failures: resolving IAM principal email from ADC, invalid ipType options, driver registration failure, or sql.Open errors. Note sql.Open rarely fails eagerly — most real problems surface at the subsequent PingContext step (a separate 'unable to connect successfully' error).
Source
Thrown at internal/sources/cloudsqlmysql/cloud_sql_mysql.go:74
Project string `yaml:"project" validate:"required"`
Region string `yaml:"region" validate:"required"`
Instance string `yaml:"instance" validate:"required"`
IPType sources.IPType `yaml:"ipType"`
User string `yaml:"user"`
Password string `yaml:"password"`
Database string `yaml:"database"`
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 := initCloudSQLMySQLConnectionPool(ctx, tracer, r.Name, r.Project, r.Region, 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.PingContext(ctx)
if err != nil {
pool.Close()
return nil, fmt.Errorf("unable to connect successfully: %w", err)
}
s := &Source{
Config: r,
Pool: pool,
}
return s, nil
}
var _ sources.Source = &Source{}
type Source struct {View on GitHub (pinned to 8cc6e09de2)
Solutions
- If using IAM auth (no user/password), ensure ADC is set up (GOOGLE_APPLICATION_CREDENTIALS or gcloud auth application-default login)
- Provide BOTH user and password, or neither — a password without a username is rejected
- Set ipType to a valid value (public or private)
- Check the wrapped error to see which pool-init step failed (config, driver registration, or sql.Open)
- Ensure the Cloud SQL Admin API is enabled and the caller has cloudsql.instances.get permission
Example fix
// before user: "" password: "secret" # password without username is rejected // after user: "myuser" password: "secret" # or remove both to use IAM auth via ADC
Defensive patterns
Strategy: validation
Validate before calling
// Before starting the toolbox, verify ADC and instance coordinates
cmd := exec.Command("gcloud", "sql", "instances", "describe", instance,
"--project", project, "--format", "value(state)")
out, err := cmd.Output()
// out == "RUNNABLE" means the instance is up; also ensure IAM auth users have
// cloudsql.instances.login permission when omitting user/password Try / catch
src, err := cfg.Initialize(ctx, tracer)
if err != nil {
if strings.Contains(err.Error(), "unable to create pool") {
return fmt.Errorf("check ADC/credentials and pool config: %w", err)
}
return err
} Prevention
- Set GOOGLE_APPLICATION_CREDENTIALS or run `gcloud auth application-default login` when using IAM auth
- Always supply user and password together, or neither — never only a password
- Use only valid ipType values (public/private)
- Grant the caller's service account roles/cloudsql.client before startup
When it happens
Trigger: Config.Initialize for a source of type 'cloud-sql-mysql' — password provided without a username, GetIAMPrincipalEmailFromADC fails (no Application Default Credentials or missing Cloud SQL scopes), sources.GetCloudSQLOpts receives an invalid ipType, mysql.RegisterDriver fails, or sql.Open gets a malformed DSN.
Common situations: Setting readOnly:true with an invalid iam principal, ADC not configured (GOOGLE_APPLICATION_CREDENTIALS unset) when relying on IAM auth, password set but user left empty (explicitly rejected), invalid ipType value other than public/private, duplicate driver registration edge cases.
Related errors
- unable to connect successfully: %w
- unable to connect successfully: %w
- unable to create connection pool: %w
- unable to create pool: %w
- unable to execute query: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/65ef617927b0d893.
Report an issue: GitHub.