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

Tool.ValidateSource type-asserts the provided sources.Source against the compatibleSource interface implemented only by Cloud Storage sources. If the tool is bound to a source of a different kind (Postgres, HTTP, etc.), the assertion fails and this error names both the tool type and the configured source name. This protects against wiring tools to incompatible sources in tools.yaml.

Source

Thrown at internal/tools/cloudstorage/cloudstoragecopyobject/cloudstoragecopyobject.go:122

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()
	sourceBucket := cloudstoragecommon.ResolveString(t.Cfg.SourceBucket, mapParams, sourceBucketKey)
	if sourceBucket == "" {
		return nil, util.NewAgentError(fmt.Sprintf("invalid or missing '%s' parameter; expected a non-empty string", sourceBucketKey), 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. Point the tool's `source:` field at a Cloud Storage source (kind: cloud-storage)
  2. Check the source's `kind` in sources.yaml matches what the tool requires
  3. Restructure tools.yaml so each tool references a source of the correct type

Example fix

// before (tools.yaml)
tools:
  copy_object:
    source: my-postgres
// after
tools:
  copy_object:
    source: my-gcs-source
Defensive patterns

Strategy: type-guard

Validate before calling

func sourceIsGCS(s sources.Source) bool {
    _, ok := s.(cloudstoragecopyobject.CompatibleSource)
    return ok
}
// before wiring: if !sourceIsGCS(src) { return fmt.Errorf("tool requires a cloud-storage source") }

Type guard

func asCompatibleSource(s sources.Source) (compatibleSource, bool) {
    cs, ok := s.(compatibleSource)
    return cs, ok
}

Try / catch

if err := tool.ValidateSource(src); err != nil {
    return fmt.Errorf("fix the tool's `source:` field in tools.yaml to a cloud-storage source: %w", err)
}

Prevention

When it happens

Trigger: Declaring a cloud-storage-copyobject tool whose `source:` points at a non-Cloud-Storage source kind in tools.yaml; programmatically passing a wrong source to the tool registry.

Common situations: Wrong `source:` key in the tool's YAML block; renaming/refactoring sources so the tool points at a leftover source; composing prebuilt configs with mismatched source kinds.

Related errors


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