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

cloudstorage-list-buckets' ValidateSource rejects sources not implementing its compatibleSource interface. The tool must be bound to a Cloud Storage source (which provides project context); binding to any other source type fails at startup.

Source

Thrown at internal/tools/cloudstorage/cloudstoragelistbuckets/cloudstoragelistbuckets.go:121

// 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()
	project := cloudstoragecommon.ResolveString(t.Cfg.Project, mapParams, projectKey)
	prefix := cloudstoragecommon.ResolveString(t.Cfg.Prefix, mapParams, prefixKey)
	pageToken, _ := mapParams[pageTokenKey].(string)
	maxResults, _ := mapParams[maxResultsKey].(int)
	if maxResults < 0 {
		return nil, util.NewAgentError(fmt.Sprintf("invalid '%s' parameter: %d must be >= 0 (use 0 for the API default)", maxResultsKey, maxResults), nil)
	}
	if maxResults > maxResultsLimit {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set `source:` to a cloudstorage source defined in the config.
  2. Move/delete the tool if attached to an incompatible source.
  3. Verify the source name matches a cloudstorage entry under `sources:`.

Example fix

# before
source: spanner-source
# after
source: gcs-project-source
Defensive patterns

Strategy: validation

Validate before calling

if _, ok := src.(compatibleSource); !ok {
    return fmt.Errorf("list-buckets requires a cloudstorage source, got %T", src)
}

Type guard

func isCompatible(s sources.Source) bool { _, ok := s.(compatibleSource); return ok }

Prevention

When it happens

Trigger: The tool config's `source` value resolves to a Go type failing the compatibleSource assertion in ValidateSource.

Common situations: Tool listed under the wrong source in the YAML; reused toolset definitions across configs; typos causing fallback to a differently-typed source.

Related errors


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