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 for cloudstorage-delete-object fails when the bound source does not implement the tool's compatibleSource interface. This guards Invoke, which type-asserts the source to obtain the Cloud Storage client.

Source

Thrown at internal/tools/cloudstorage/cloudstoragedeleteobject/cloudstoragedeleteobject.go:111

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)
	}
	object, ok := mapParams[objectKey].(string)
	if !ok || object == "" {
		return nil, util.NewAgentError(fmt.Sprintf("invalid or missing '%s' parameter; expected a non-empty string", objectKey), nil)
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool's source field at a cloudstorage source
  2. Confirm the source initializes successfully (client creation) before tool validation
  3. Regenerate/validate the toolbox config with `toolbox` startup to catch mismatches early

Example fix

// before
tools:
  delete-object:
    kind: cloudstorage-delete-object
    source: my-postgres
// after
tools:
  delete-object:
    kind: cloudstorage-delete-object
    source: my-gcs
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := sources[toolCfg.Source].(cloudstorage.Source); !ok {
    log.Fatalf("delete-object tool must bind a cloudstorage source")
}

Type guard

func isGCSCompatible(s sources.Source) bool {
    _, ok := s.(cloudstorage.CompatibleSource)
    return ok
}

Prevention

When it happens

Trigger: tools.yaml binds cloudstorage-delete-object to a source of a non-cloudstorage kind (or a cloudstorage source missing the required client interface), causing the type assertion to fail during tool/source validation.

Common situations: Wrong source name in the tool config; source kind changed after a refactor; reusing a shared tools.yaml across projects with different source definitions.

Related errors


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