googleapis/mcp-toolbox · error
unsupported dbType: %s. Use 'mysql' or 'postgres'
Error message
unsupported dbType: %s. Use 'mysql' or 'postgres'
What it means
GetIAMPrincipalEmailFromADC derives the IAM principal email from Application Default Credentials for Cloud SQL IAM authentication. It only supports 'mysql' and 'postgres' dbTypes; any other value (including empty or typos like 'postgresql') hits the default branch and returns this error. The library throws it to fail fast rather than attempt IAM auth against an unsupported database engine.
Source
Thrown at internal/sources/util.go:136
}
fullEmail, ok := emailValue.(string)
if !ok {
return "", fmt.Errorf("email field is not a string")
}
var username string
// Format the username based on Database Type
switch strings.ToLower(dbType) {
case "mysql":
username, _, _ = strings.Cut(fullEmail, "@")
case "postgres":
// service account email used for IAM should trim the suffix
username = strings.TrimSuffix(fullEmail, ".gserviceaccount.com")
default:
return "", fmt.Errorf("unsupported dbType: %s. Use 'mysql' or 'postgres'", dbType)
}
if username == "" {
return "", fmt.Errorf("username from ADC cannot be an empty string")
}
return username, nil
}
func GetIAMAccessToken(ctx context.Context) (string, error) {
creds, err := google.FindDefaultCredentials(ctx, "https://www.googleapis.com/auth/cloud-platform")
if err != nil {
return "", fmt.Errorf("failed to find default credentials (run 'gcloud auth application-default login'?): %w", err)
}
token, err := creds.TokenSource.Token() // This gets an oauth2.Token
if err != nil {
return "", fmt.Errorf("failed to get token from token source: %w", err)View on GitHub (pinned to 8cc6e09de2)
Solutions
- Fix the dbType in your source config to exactly 'mysql' or 'postgres' (lowercase)
- If using Postgres, use kind 'postgres', not 'postgresql'
- If your database is not MySQL or Postgres, do not use ADC-based IAM auth; use a standard username/password connection instead
Example fix
// before
sources:
my-pg:
kind: postgresql
// after
sources:
my-pg:
kind: postgres Defensive patterns
Strategy: validation
Validate before calling
const allowed = new Set(["mysql", "postgres"]);
if (!allowed.has(dbType)) {
throw new Error(`dbType must be 'mysql' or 'postgres', got: ${dbType}`);
} Type guard
function isSupportedDbType(v: string): v is "mysql" | "postgres" {
return v === "mysql" || v === "postgres";
} Prevention
- Copy dbType values verbatim from official docs ('postgres', not 'postgresql')
- Validate your tools.yaml source kinds against supported values before startup
- Add a config linter/schema check in CI for source kinds
When it happens
Trigger: Calling getConnectionConfig (which calls GetIAMPrincipalEmailFromADC) with a Cloud SQL source whose dbType is not exactly 'mysql' or 'postgres' — e.g. 'postgresql', 'sqlserver', 'mssql', or an unset/empty dbType in the source config.
Common situations: Typo in the source kind (using 'postgresql' instead of 'postgres'); using Cloud SQL IAM auth fields with an unsupported engine like SQL Server; a config file where dbType is omitted or mis-indented in YAML.
Related errors
- username from ADC cannot be an empty string
- environment variable not found: %s
- environment variables not found: - %s
- error parsing environment variables: %s
- error converting config file: %s
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/41e43dfc0616cb67.
Report an issue: GitHub.