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

Source-compatibility check in ValidateSource: the source named by the tool's `source` field does not implement the Cloud Storage compatibleSource interface, i.e. the tool is bound to a non-cloud-storage source kind.

Source

Thrown at internal/tools/cloudstorage/cloudstoragedownloadobject/cloudstoragedownloadobject.go:133

// validate interface
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. Bind the tool to a cloudstorage source
  2. Verify the source initializes and provides the required storage client
  3. Validate the full toolbox config at startup

Example fix

// before
source: my-spanner
// after
source: my-gcs
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

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

Prevention

When it happens

Trigger: The tool's source field references a non-cloudstorage source (or an incompatible cloudstorage source variant), so the type assertion fails during validation.

Common situations: Wrong source name after renaming; reusing configs across projects; upgrading where the source kind/client changed.

Related errors


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