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-execute-sql type-asserts the source to compatibleSource (SpannerClient, DatabaseDialect, RunSQL). A source of any other type fails the assertion and produces this error during config validation.

Source

Thrown at internal/tools/spanner/spannerexecutesql/spannerexecutesql.go:132

	resp, err := source.RunSQL(ctx, t.Cfg.ReadOnly, sql, nil)
	if err != nil {
		return nil, util.ProcessGcpError(err)
	}
	return resp, nil
}

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
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool's `source:` at a source defined with kind spanner (or alloydb-spanner-compatible).
  2. Verify the source name exists in the `sources:` section and is of the Spanner type.
  3. When building tools in code, pass the concrete Spanner source to ValidateSource.

Example fix

// before
execute-sql:
  kind: spanner-execute-sql
  source: my-postgres
// after
execute-sql:
  kind: spanner-execute-sql
  source: my-spanner
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

func toSpannerSource(s sources.Source) (compatibleSource, error) {
	if cs, ok := s.(compatibleSource); ok {
		return cs, nil
	}
	return nil, fmt.Errorf("%T is not a spanner compatibleSource", s)
}

Prevention

When it happens

Trigger: ValidateSource receives a non-Spanner source while validating a spanner-execute-sql tool — e.g. the tool's `source:` field references a postgres or mysql source.

Common situations: Wrong `source:` reference in tools.yaml; sources renamed/swapped during refactors; reusing a prebuilt spanner config against a different database kind.

Related errors


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