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

Same family as error 1140: clickhouse-list-databases' ValidateSource type-asserts the incoming sources.Source to its private `compatibleSource` interface and errors when the source is any other kind. This guards that the tool only runs against ClickHouse sources.

Source

Thrown at internal/tools/clickhouse/clickhouselistdatabases/clickhouselistdatabases.go:100

var _ tools.Tool = Tool{}

type Tool struct {
	tools.BaseTool[Config]
}

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
}

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)
	}
	// Query to list all databases
	query := "SHOW DATABASES"

	out, err := source.RunSQL(ctx, query, nil)
	if err != nil {
		return nil, util.ProcessGeneralError(err)
	}

	return out, nil

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool at a `clickhouse`-kind source.
  2. Check for copy/paste mistakes in the `source:` field of the tool config.
  3. For custom sources, satisfy the compatibleSource interface the tool asserts.
Defensive patterns

Strategy: validation

Validate before calling

// Validate the tool against its bound source during setup
if err := tool.ValidateSource(mySource); err != nil {
    return fmt.Errorf("tool/source wiring invalid: %w", err)
}

Type guard

func isCompatible(s sources.Source) bool {
    _, ok := s.(interface{ DB() *sql.DB })
    return ok
}

Prevention

When it happens

Trigger: Server startup or tool invocation where the tool's bound source is not a ClickHouse source (wrong `source:` reference in YAML, or programmatic registration of a non-compatible source).

Common situations: Miswired tool-to-source references in toolbox YAML; sharing one tool definition across multiple source kinds; tests passing a mock source that doesn't implement the accessor interface.

Related errors


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