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

ValidateSource on the cloud-sql-connect-gce tool performs a type assertion of the bound source to `compatibleSource`; when the assertion fails it returns this error. The tool only supports sources that can provide the SQL admin service and Cloud SQL Connect GCE capabilities. It is an early compatibility check, so the error means the tool was wired to a wrong-kind source.

Source

Thrown at internal/tools/cloudsql/cloudsqlconnectgce/cloudsqlconnectgce.go:145

		),
	}
}

var _ tools.Tool = Tool{}

// Tool represents the cloud-sql-connect-gce tool.
type Tool struct {
	tools.BaseTool[Config]
}

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

func (t Tool) ValidateSource(src sources.Source) error {
	_, ok := src.(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
}

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

// Invoke fetches the Cloud SQL instance, detects its engine, validates
// connectivity to the target VM, and returns connection recommendations.
func (t Tool) Invoke(ctx context.Context, s sources.Source, params parameters.ParamValues, accessToken tools.AccessToken) (any, util.ToolboxError) {
	source, ok := s.(compatibleSource)
	if !ok {
		return nil, util.NewClientServerError("source used is not compatible with the tool", http.StatusInternalServerError, nil)
	}

	sqlService, err := source.GetService(ctx, string(accessToken))
	if err != nil {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's `source:` to a Cloud SQL source compatible with connect-gce (implements GetDefaultProject, GetService, UseClientAuthorization, and the connect methods).
  2. Cross-check the source kind in sources config; only cloudsql* sources satisfy compatibleSource for this tool.
  3. If a custom source is intended, implement all compatibleSource interface methods.
  4. Run server startup and read the validation error's quoted source name (Cfg.Source) to fix the exact miswired entry.

Example fix

# before
sources:
  db:
    kind: postgres
    ...
tools:
  connect-gce:
    kind: cloud-sql-connect-gce
    source: db

# after
sources:
  db:
    kind: cloudsqlpostgres
    ...
tools:
  connect-gce:
    kind: cloud-sql-connect-gce
    source: db
Defensive patterns

Strategy: validation

Validate before calling

// Go: run ValidateSource yourself at startup before serving traffic
if err := tool.ValidateSource(src); err != nil {
    log.Fatalf("config error: %v", err)
}

Try / catch

if err := tool.ValidateSource(source); err != nil {
    return fmt.Errorf("cloud-sql-connect-gce bound to incompatible source %T: %w", source, err)
}

Prevention

When it happens

Trigger: Calling ValidateSource (invoked when the tool is attached to a source, e.g., during config load or tool resolution) with a sources.Source that does not implement the tool's compatibleSource interface — the tool's `source` field names a non-Cloud-SQL or non-connect-capable source.

Common situations: Configuring `cloud-sql-connect-gce` against a vanilla postgres/mysql source; a renamed or custom source type lacking the required methods; copying a tool definition into a prebuilt config where the source kind differs; typos in the source name resolving to an unrelated source.

Related errors


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