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-list-tables requires the source to implement compatibleSource (SpannerClient, DatabaseDialect, RunSQL) since the tool issues dialect-specific list-tables statements. Any other source type fails the assertion and triggers this error.

Source

Thrown at internal/tools/spanner/spannerlisttables/spannerlisttables.go:171

	resp, err := source.RunSQL(ctx, true, statement, stmtParams)
	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
}

// PostgreSQL statement for listing tables
const postgresqlStatement = `
WITH table_info_cte AS (
    SELECT
      T.TABLE_SCHEMA,
      T.TABLE_NAME,
      T.TABLE_TYPE,
      T.PARENT_TABLE_NAME,
      T.ON_DELETE_ACTION
    FROM INFORMATION_SCHEMA.TABLES AS T
    WHERE
      T.TABLE_SCHEMA = 'public'
      AND T.TABLE_TYPE = 'BASE TABLE'
      AND (

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's `source:` to a spanner-kind source.
  2. Audit the `sources:` block so the referenced name is the intended Spanner instance.
  3. Pass the concrete Spanner source when constructing/validating tools in Go.

Example fix

// before
list-tables:
  kind: spanner-list-tables
  source: my-postgres-source
// after
list-tables:
  kind: spanner-list-tables
  source: my-spanner-source
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

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

Prevention

When it happens

Trigger: Startup validation of a spanner-list-tables tool bound via `source:` to a non-Spanner source (postgres, mysql, bigquery, etc.).

Common situations: Misconfigured tools.yaml source reference; prebuilt-config reuse against the wrong engine; programmatic tool construction with a mismatched Source.

Related errors


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