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

ValidateSource ensures the source attached to the get-dicom-store-metrics tool implements compatibleSource (a Cloud Healthcare source exposing allowed DICOM stores). Incompatible sources cannot provide the store context the tool needs, so validation fails.

Source

Thrown at internal/tools/cloudhealthcare/cloudhealthcaregetdicomstoremetrics/cloudhealthcaregetdicomstoremetrics.go:101

// 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)
	}
	storeID, err := common.ValidateAndFetchStoreID(params, source.AllowedDICOMStores())
	if err != nil {
		return nil, util.NewAgentError("failed to validate store ID", err)
	}
	var tokenStr string
	if source.UseClientAuthorization() {
		tokenStr, err = accessToken.ParseBearerToken()
		if err != nil {
			return nil, util.NewClientServerError("error parsing access token", http.StatusUnauthorized, err)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool at a cloudhealthcare source
  2. Fix the source kind in the config
  3. Verify source-tool compatibility at config load time

Example fix

# before
source: analytics_db
# after
source: healthcare_api
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := source.(compatibleSource); !ok {
    return fmt.Errorf("source %T unsupported for dicom-store-metrics", source)
}

Type guard

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

Prevention

When it happens

Trigger: Calling ValidateSource with a sources.Source that is not a Cloud Healthcare compatibleSource.

Common situations: sourceRef in tool YAML pointing at a non-healthcare source; refactors that changed source kinds; stale configs after migrating sources.

Related errors


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