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-template tool throws this from ValidateSource when the configured source fails the `compatibleSource` type assertion, i.e. it is not a Serverless Spark source with the required session-template client method. Toolbox enforces this check when the tool is initialized against its configured source so incompatible pairings never reach Invoke.

Source

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

	res, err := source.GetSessionTemplate(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. Change the tool's `source` to the name of a `serverless-spark` kind source.
  2. Add a `kind: serverless-spark` source to tools.yaml if none exists, then reference it.
  3. Audit all serverless-spark-* tools' source fields when refactoring the sources section.

Example fix

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

Strategy: validation

Validate before calling

sources:
  spark-src:
    kind: serverless-spark
tools:
  get-template:
    kind: serverless-spark-get-session-template
    source: spark-src

Type guard

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

Prevention

When it happens

Trigger: Declaring a `serverless-spark-get-session-template` tool whose `source` references a non-serverless-spark source (e.g. postgres, bigquery, http), making the interface assertion in ValidateSource fail.

Common situations: Reusing a single shared `source:` anchor across tools of different kinds; template scaffolding that left a placeholder source name; team members adding tools without a matching Spark source in the environment.

Related errors


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