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

Identical type-compatibility guard as the other Serverless Spark tools: serverlesssparkcancelbatch.ValidateSource requires the bound source to implement its compatibleSource interface (CancelBatch capability). A mismatched source kind fails config initialization with this error, which names the tool type and source name for diagnosis.

Source

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

	resp, err := source.CancelOperation(ctx, operation)
	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. Verify the cancel-batch tool's 'source:' points to a serverlessspark source in the YAML
  2. Update the source reference to the correct Serverless Spark source
  3. Restart and confirm the tool initializes

Example fix

# before
tools:
  cancel-batch:
    source: alloydb-src
# after
tools:
  cancel-batch:
    source: spark-src
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := src.(cancelbatch.CompatibleSource); !ok {
    return fmt.Errorf("source %T cannot back cancel-batch tool", src)
}
err := tool.ValidateSource(src)

Type guard

func isCancelBatchSource(s sources.Source) bool {
    _, ok := s.(serverlesssparkcancelbatch.CompatibleSource)
    return ok
}

Try / catch

if err := tool.ValidateSource(src); err != nil {
    log.Fatalf("cancel-batch tool requires a serverlessspark source: %v", err)
}

Prevention

When it happens

Trigger: A cancel-batch tool config references a source not implementing the Serverless Spark compatibleSource interface — e.g. wired to a Postgres/BigQuery source — during toolbox startup validation.

Common situations: Template-based config edits where the tool's source key still points at a database source; multi-source YAML files where two sources share a similar name and the wrong one is referenced.

Related errors


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