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-list-batches tool throws this in ValidateSource when its configured source does not implement the tool's `compatibleSource` interface, meaning it is not a Serverless Spark source that can supply a batch admin client. This is a startup-time configuration validation, not a runtime database failure — the tool never executes because its source type is wrong.
Source
Thrown at internal/tools/serverlessspark/serverlesssparklistbatches/serverlesssparklistbatches.go:142
resp, err := source.ListBatches(ctx, pageSize, pt, filter)
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
- Set `source:` to a declared `kind: serverless-spark` source.
- Fix the sources block so the referenced source is actually serverless-spark (check `kind` field).
- Run `./toolbox --tools-file` validation/dev UI startup locally to catch all incompatible pairings at once.
Example fix
# before
tools:
list-batches:
kind: serverless-spark-list-batches
source: cloudsql-pg
# after
tools:
list-batches:
kind: serverless-spark-list-batches
source: serverless-spark-prod Defensive patterns
Strategy: validation
Validate before calling
# ensure the referenced source kind matches
sources:
spark-prod:
kind: serverless-spark
tools:
list-batches:
kind: serverless-spark-list-batches
source: spark-prod Type guard
func isServerlessSparkSource(s sources.Source) bool {
_, ok := s.(serverlessspark.Source)
return ok
} Prevention
- In multi-environment overlays, re-verify each tool's source after substitution.
- Add a lint step that cross-checks tool kinds against source kinds in tools.yaml.
- Document the required source kind next to each tool definition.
When it happens
Trigger: A `serverless-spark-list-batches` tool bound via `source:` to a source of any kind other than `serverless-spark`, so the assertion `source.(compatibleSource)` in serverlesssparklistbatches.go fails.
Common situations: Bulk-edited tools.yaml where many tools share one wrong source name; environment-specific overlays (staging/prod) replacing the Spark source with another type; forgetting that each tool kind only accepts its matching source kind.
Related errors
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/5f3cdebfff805ec8.
Report an issue: GitHub.