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

ValidateSource for the serverlessspark createbatch tool asserts the bound source implements compatibleSource — specifically a source offering CreateBatch(ctx, *dataprocpb.Batch). If the tool is wired to a non-Serverless-Spark source, startup fails with this type-compatibility error naming the tool type and configured source.

Source

Thrown at internal/tools/serverlessspark/createbatch/tool.go:68

		originalConfig: originalCfg,
		Builder:        builder,
	}, nil
}

type Tool struct {
	tools.BaseTool[Config]
	originalConfig tools.ToolConfig
	Builder        BatchBuilder
}

func (t Tool) GetSourceName() string {
	return t.Cfg.Source
}

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
}

func (t *Tool) Invoke(ctx context.Context, s sources.Source, params parameters.ParamValues, accessToken tools.AccessToken) (any, util.ToolboxError) {
	source, ok := s.(compatibleSource)
	if !ok {
		return nil, util.NewClientServerError("source used is not compatible with the tool", http.StatusInternalServerError, nil)
	}
	batch, err := t.Builder.BuildBatch(params)
	if err != nil {
		if tbErr, ok := err.(util.ToolboxError); ok {
			return nil, tbErr
		}
		return nil, util.NewAgentError("failed to build batch", err)
	}

	if t.Cfg.RuntimeConfig != nil {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Check the tool's 'source:' reference in the YAML and ensure it points to a serverlessspark kind source
  2. Correct the source reference or add a dedicated serverlessspark source
  3. Restart the server to reload configs

Example fix

# before
tools:
  create-batch:
    source: my-postgres
# after
tools:
  create-batch:
    source: my-spark
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := src.(createbatch.CompatibleSource); !ok {
    return fmt.Errorf("source %T lacks CreateBatch; use a serverlessspark source", src)
}
err := tool.ValidateSource(src)

Type guard

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

Try / catch

if err := tool.ValidateSource(src); err != nil {
    log.Fatalf("create-batch tool mis-bound: %v — fix 'source:' in YAML", err)
}

Prevention

When it happens

Trigger: Tool config assigns 'type: serverless-spark-create-batch' to a source (e.g. postgres, alloydb) whose Go type does not implement compatibleSource, evaluated when the toolbox loads the config.

Common situations: Reusing a shared sources block across tool kinds and pointing a Spark batch tool at a database source; renaming sources so an old source reference now resolves to a different kind.

Related errors


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