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

This error is thrown by the serverlessspark-get-batch tool's ValidateSource when the source wired to the tool does not implement the tool's private `compatibleSource` interface (a Serverless Spark source exposing the batch client). In MCP Toolbox, each tool is attached to a named source in tools.yaml, and ValidateSource enforces that the referenced source's concrete type is compatible before the tool can be used. If you point the tool at a source of a different kind (e.g. a Postgres source) the type assertion fails and this message is returned at config load time.

Source

Thrown at internal/tools/serverlessspark/serverlesssparkgetbatch/serverlesssparkgetbatch.go:129

	resp, err := source.GetBatch(ctx, name)
	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. Set the tool's `source` field in tools.yaml to the name of a source declared with `kind: serverless-spark`.
  2. Check the source entry's `kind` under `sources:` matches the tool type (serverless-spark) and fix typos in the source name.
  3. If the source should be a different database, use the corresponding tool kind for that source instead of serverless-spark-get-batch.

Example fix

# before
sources:
  my-pg:
    kind: postgres
    ...
tools:
  get-batch:
    kind: serverless-spark-get-batch
    source: my-pg
# after
sources:
  my-spark:
    kind: serverless-spark
    project: my-project
    ...
tools:
  get-batch:
    kind: serverless-spark-get-batch
    source: my-spark
Defensive patterns

Strategy: validation

Validate before calling

// before starting toolbox, check the pairing in tools.yaml
sources:
  spark-prod:
    kind: serverless-spark
    project: my-project
    region: us-central1
    location: us-central1
tools:
  get-batch:
    kind: serverless-spark-get-batch
    source: spark-prod   # must reference a kind: serverless-spark source

Type guard

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

Prevention

When it happens

Trigger: Configuring a tool of kind `serverless-spark-get-batch` whose `source` field references a source that is not a `serverless-spark` source (any other source type, or a source left as a different engine), causing the `source.(compatibleSource)` type assertion in ValidateSource to fail.

Common situations: Copy-pasting a tools.yaml block and forgetting to change the `source` name; renaming or restructuring sources so the tool now binds to the wrong source; mixing sources in one config (e.g. alloydb + serverless-spark) and mismatching the kind/source pairing.

Related errors


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