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

Thrown by cloudstorage-move-object ValidateSource when the provided sources.Source does not satisfy the tool's compatibleSource interface. Only Cloud Storage sources can back this tool; any other source kind fails the type assertion.

Source

Thrown at internal/tools/cloudstorage/cloudstoragemoveobject/cloudstoragemoveobject.go:113

var _ tools.Tool = 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)
	}
	mapParams := params.AsMap()
	bucket := cloudstoragecommon.ResolveString(t.Cfg.Bucket, mapParams, bucketKey)
	if bucket == "" {
		return nil, util.NewAgentError(fmt.Sprintf("invalid or missing '%s' parameter; expected a non-empty string", bucketKey), nil)
	}
	sourceObject, ok := mapParams[sourceObjectKey].(string)
	if !ok || sourceObject == "" {
		return nil, util.NewAgentError(fmt.Sprintf("invalid or missing '%s' parameter; expected a non-empty string", sourceObjectKey), nil)
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's `source` to a cloud-storage kind source
  2. Confirm the source name matches an entry defined under sources in tools.yaml
  3. Reload the config and re-run to verify validation passes

Example fix

// before
  move-object:
    kind: cloudstorage-move-object
    source: my-mysql
// after
  move-object:
    kind: cloudstorage-move-object
    source: my-gcs
Defensive patterns

Strategy: type-guard

Validate before calling

// ensure the referenced source kind matches before binding
if cfg.SourceKind != "cloud-storage" {
    return fmt.Errorf("tool %s requires a cloud-storage source, got %s", cfg.Name, cfg.SourceKind)
}

Type guard

func isCompatibleSource(s sources.Source) bool {
    _, ok := s.(interface{ GCSClient() *storage.Client });
    return ok
}

Prevention

When it happens

Trigger: Tool config references a non-cloud-storage source via `source:`; ValidateSource called programmatically with an incompatible source implementation.

Common situations: Misconfigured source reference after copying another tool's YAML; refactoring source names and leaving the tool pointed at a database source.

Related errors


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