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 for cloudhealthcare-get-dataset asserts the bound source implements the tool's compatibleSource interface (UseClientAuthorization and GetDataset per internal/tools/cloudhealthcare/cloudhealthcaregetdataset/cloudhealthcaregetdataset.go:46). Any other source type fails the assertion and produces this error. It is a wiring check performed when the tool is bound to a source.

Source

Thrown at internal/tools/cloudhealthcare/cloudhealthcaregetdataset/cloudhealthcaregetdataset.go:100

// 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)
	}
	var tokenStr string
	var err error
	if source.UseClientAuthorization() {
		tokenStr, err = accessToken.ParseBearerToken()
		if err != nil {
			return nil, util.NewClientServerError("error parsing access token", http.StatusUnauthorized, err)
		}
	}
	resp, err := source.GetDataset(tokenStr)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Bind the tool to a kind: cloudhealthcare source in tools.yaml.
  2. Fix the source name referenced by the tool.
  3. Implement GetDataset(string) (*healthcare.Dataset, error) and UseClientAuthorization() bool on custom sources.
  4. Rebuild so the concrete cloudhealthcare Source is registered.

Example fix

# before
source: my-spanner

# after
source: my-healthcare  # kind: cloudhealthcare
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := src.(compatibleSource); !ok {
	return errors.New("cloudhealthcare-get-dataset requires a cloudhealthcare source (with GetDataset)")
}

Type guard

cs, ok := src.(compatibleSource)

Try / catch

if err := tool.ValidateSource(src); err != nil {
	log.Fatalf("bad tool/source binding: %v", err) // config bug, no retry
}

Prevention

When it happens

Trigger: ValidateSource(source) is called with a source that is not the cloudhealthcare Source — e.g. a postgres/http source, or a stub missing GetDataset/UseClientAuthorization.

Common situations: tools.yaml binds the tool to a source of the wrong kind; a source-name typo; custom test doubles missing interface methods; refactor broke interface compliance.

Related errors


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