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-create-backup tool asserts the bound source implements `compatibleSource`; failing the assertion returns this error. The tool can only create Cloud SQL backups through sources that expose the SQL admin service and backup operations. The error means the tool was attached to a source of the wrong kind.

Source

Thrown at internal/tools/cloudsql/cloudsqlcreatebackup/cloudsqlcreatebackup.go:101

}

// Tool represents the create-backup tool.
type Tool struct {
	tools.BaseTool[Config]
}

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
}

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)
	}
	paramsMap := params.AsMap()

	project, ok := paramsMap["project"].(string)
	if !ok {
		return nil, util.NewAgentError(fmt.Sprintf("error casting 'project' parameter: %v", paramsMap["project"]), nil)
	}
	instance, ok := paramsMap["instance"].(string)
	if !ok {
		return nil, util.NewAgentError(fmt.Sprintf("error casting 'instance' parameter: %v", paramsMap["instance"]), nil)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Change the tool's `source:` field to a Cloud SQL source implementing compatibleSource (cloudsqlpg, cloudsqlmysql, cloudsqlmssql, etc.).
  2. Verify the source's kind and name in the config; the error quotes the misconfigured source name.
  3. If a custom source is intended, implement all compatibleSource methods including CreateBackup.
  4. Reload the server config; ValidateSource should pass at startup.

Example fix

# before
tools:
  create-backup:
    kind: cloud-sql-create-backup
    source: postgres-source

# after
tools:
  create-backup:
    kind: cloud-sql-create-backup
    source: cloudsql-postgres-source
Defensive patterns

Strategy: validation

Validate before calling

// Go: validate binding before invoking
if err := tool.ValidateSource(src); err != nil {
    log.Fatalf("create-backup source invalid: %v", err)
}

Type guard

func canCreateBackup(s sources.Source) bool {
    _, ok := s.(interface {
        GetDefaultProject() string
        GetService(context.Context, string) (*sqladmin.Service, error)
        UseClientAuthorization() bool
    })
    return ok
}

Try / catch

if err := tool.ValidateSource(source); err != nil {
    return fmt.Errorf("cloud-sql-create-backup requires a cloudsql* source: %w", err)
}

Prevention

When it happens

Trigger: Calling ValidateSource during tool/source binding (config load or tool resolution) with a sources.Source that does not satisfy the tool's compatibleSource interface — the tool's `source` field names a non-Cloud-SQL source such as a plain postgres or mysql source.

Common situations: tools.yml `create-backup` tool pointed at a database source instead of a cloudsql* source; a custom source missing GetDefaultProject/GetService/UseClientAuthorization/CreateBackup; typos or refactors that swapped the source name; toolbox version upgrades adding methods to compatibleSource.

Related errors


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