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 in spanner-search-catalog performs a type assertion of the provided source to compatibleSource (SpannerClient, DatabaseDialect, RunSQL). Sources that do not implement it cause this error, which surfaces when the toolbox validates the tool against its configured source.

Source

Thrown at internal/tools/spanner/spannersearchcatalog/spannersearchcatalog.go:123

// 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) RequiresClientAuthorization(source sources.Source) (bool, error) {
	s, ok := source.(compatibleSource)
	if !ok {
		return false, fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", t.Cfg.Type, t.Cfg.Source)
	}
	return s.UseClientAuthorization(), 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

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point `source:` at a Spanner source (with SPANNER_SEARCH / search-index support for the catalog).
  2. Verify the source implements compatibleSource before registering the tool.
  3. Fix any renamed/duplicated source names in the config.

Example fix

// before
search-catalog:
  kind: spanner-search-catalog
  source: my-alloydb
// after
search-catalog:
  kind: spanner-search-catalog
  source: my-spanner
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := source.(compatibleSource); !ok {
	return errors.New("spanner-search-catalog requires a Spanner source")
}

Type guard

cs, ok := source.(compatibleSource)
if !ok { return errors.New("spanner-search-catalog needs a spanner compatibleSource") }

Prevention

When it happens

Trigger: ValidateSource called with a non-Spanner source for a spanner-search-catalog tool — typically because the YAML `source:` points at another database's source.

Common situations: Wrong source kind in tools.yaml; refactors renaming sources so the tool binds to the wrong one; copying prebuilt spanner configs to non-Spanner setups.

Related errors


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