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

The serverlessspark-get-session tool throws this in its ValidateSource method when the bound source does not satisfy the tool's `compatibleSource` interface (a Serverless Spark source able to create session clients). The library validates tool/source compatibility at startup so misconfiguration is caught before any request. A type assertion failure means the named source exists but is of a different kind than the tool requires.

Source

Thrown at internal/tools/serverlessspark/serverlesssparkgetsession/serverlesssparkgetsession.go:128

	res, err := source.GetSession(ctx, name)
	if err != nil {
		return nil, util.ProcessGcpError(err)
	}
	return res, 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 `kind: serverless-spark` source in tools.yaml.
  2. Verify source name spelling and that the source block still exists with the serverless-spark kind.
  3. Remove or replace the tool if it no longer matches your intended source type.

Example fix

# before
tools:
  get-session:
    kind: serverless-spark-get-session
    source: mysql-src
# after
tools:
  get-session:
    kind: serverless-spark-get-session
    source: spark-src  # kind: serverless-spark
Defensive patterns

Strategy: validation

Validate before calling

tools:
  get-session:
    kind: serverless-spark-get-session
    source: spark-src  # source must be kind: serverless-spark

Type guard

func isServerlessSparkSource(s sources.Source) bool {
    _, ok := s.(serverlessspark.Source)
    return ok
}

Prevention

When it happens

Trigger: A `serverless-spark-get-session` tool whose `source` field names a source whose concrete Go type is not the Serverless Spark source, so `source.(compatibleSource)` returns ok=false.

Common situations: tools.yaml with multiple sources where the tool references the wrong one; a refactored config where the Spark source was renamed/deleted and the name now resolves to another source; hand-edited YAML merging two example configs.

Related errors


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