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-graphs asserts the configured source implements compatibleSource (SpannerClient plus graph-supporting dialect). Non-Spanner sources fail the assertion, yielding this error at config validation time.

Source

Thrown at internal/tools/spanner/spannerlistgraphs/spannerlistgraphs.go:141

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

// GoogleSQL statement for listing graphs
const googleSQLStatement = `
WITH FilterGraphNames AS (
  SELECT DISTINCT TRIM(name) AS GRAPH_NAME
  FROM UNNEST(IF(@graph_names = '' OR @graph_names IS NULL, ['%'], SPLIT(@graph_names, ','))) AS name
)

SELECT
	PG.PROPERTY_GRAPH_SCHEMA AS schema_name,
  PG.PROPERTY_GRAPH_NAME AS object_name,
  CASE
    WHEN @output_format = 'simple' THEN
      -- IF format is 'simple', return basic JSON
          CONCAT('{"name":"', IFNULL(REPLACE(PG.PROPERTY_GRAPH_NAME, '"', '\"'), ''), '"}')

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Reference a Spanner source (kind spanner) with Spanner Graph support in the tool's `source:` field.
  2. Confirm the source implements compatibleSource (SpannerClient, DatabaseDialect, RunSQL).
  3. If using Spanner Graph, ensure the database dialect supports graphs before binding this tool.

Example fix

// before
list-graphs:
  kind: spanner-list-graphs
  source: my-mysql
// after
list-graphs:
  kind: spanner-list-graphs
  source: my-spanner-graph
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

cs, ok := source.(compatibleSource)
if !ok || cs.DatabaseDialect() not graph-enabled {
	return errors.New("source must be a graph-capable Spanner source")
}

Prevention

When it happens

Trigger: Validating a spanner-list-graphs tool whose `source:` resolves to a source type that does not implement compatibleSource (e.g. a non-Spanner database source, or a Spanner source not configured for PG/GoogleSQL graph dialects).

Common situations: Wiring spanner-list-graphs to a plain SQL source; using the tool against a Spanner database without graph support configured; config copy-paste errors.

Related errors


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