googleapis/mcp-toolbox · error

invalid source for %q tool: source %q is not a compatible ty

Error message

invalid source for %q tool: source %q is not a compatible type

What it means

cloudsqlmysql-create-instance is wired to Cloud SQL Admin sources only. RequiresClientAuthorization type-asserts the injected sources.Source to the tool's private compatibleSource interface; when the configured source is any other source kind (e.g. a plain mysql/postgres database source), the assertion fails and this error is returned instead of an authorization decision.

Source

Thrown at internal/tools/cloudsqlmysql/cloudsqlmysqlcreateinstance/cloudsqlmysqlcreateinstance.go:154

	}

	resp, err := source.CreateInstance(ctx, project, name, dbVersion, rootPassword, settings, string(accessToken))
	if err != nil {
		return nil, util.ProcessGcpError(err)
	}
	return resp, nil
}

// Authorized always returns true: this admin tool intentionally bypasses
// per-request auth-service checks (server-side credentials handle access).
func (t Tool) Authorized(verifiedAuthServices []string) bool {
	return true
}

func (t Tool) RequiresClientAuthorization(source sources.Source) (bool, error) {
	s, ok := source.(compatibleSource)
	if !ok {
		return false, fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", t.Cfg.Type, t.Cfg.Source)
	}
	return s.UseClientAuthorization(), nil
}

func (t Tool) GetSourceName() string {
	return t.Cfg.Source
}

func (t Tool) ToConfig() tools.ToolConfig {
	return t.Cfg
}

func (t Tool) ValidateSource(source sources.Source) error {
	_, ok := source.(compatibleSource)
	if !ok {
		return fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", t.Cfg.Type, t.Cfg.Source)
	}
	return nil

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool's `source` field in the YAML config at a Cloud SQL MySQL source (kind `cloud-sql-mysql`) that implements UseClientAuthorization/GetDefaultProject
  2. Verify with `toolbox --tools` or the tool manifest that the resolved source name matches the intended cloudsql source
  3. If you truly need a non-CloudSQL source, use a tool designed for that source instead of cloudsqlmysql-create-instance

Example fix

// before
tools:
  create-instance:
    kind: cloud-sql-mysql-create-instance
    source: my-mysql   # plain mysql source
// after
tools:
  create-instance:
    kind: cloud-sql-mysql-create-instance
    source: my-cloudsql-mysql  # cloud-sql-mysql source
Defensive patterns

Strategy: type-guard

Validate before calling

_, ok := src.(cloudsqlmysqlsource.CompatibleSource); if !ok { return fmt.Errorf("tool %s requires a cloud-sql-mysql source", toolName) }

Type guard

func isCloudSQLMySQLSource(s sources.Source) bool { _, ok := s.(interface{ UseClientAuthorization() bool; GetDefaultProject() string }); return ok }

Try / catch

ok, err := tool.RequiresClientAuthorization(src)
if err != nil {
    if strings.Contains(err.Error(), "not a compatible type") {
        // rebind tool to a cloud-sql-mysql source before proceeding
    }
    return err
}

Prevention

When it happens

Trigger: Calling RequiresClientAuthorization (directly or via server startup/auth middleware) while the tool is bound to a source whose concrete type does not implement compatibleSource — for example attaching the tool to a `mysql` source instead of a `cloud-sql-mysql` source, or renaming/swapping source kinds in the YAML config without updating the tool's `source` field.

Common situations: Copy-pasting a tool config between prebuilt configs and leaving the source pointing at the wrong kind; upgrading toolbox versions where the tool narrowed which sources it accepts; typos in the source name causing fallback to an unexpected source; mixing dataplex/cloud-sql sources across tools in one config.

Related errors


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