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

Tool.ValidateSource rejects a source whose Go type does not implement the tool's private `compatibleSource` interface (a ClickHouse source with a DB() accessor). The toolbox only allows a tool to run against sources declared as compatible with it; any other source type fails this check before Invoke is called. It is a config/wiring error surfaced as a defensive runtime check.

Source

Thrown at internal/tools/clickhouse/clickhouseexecutesql/clickhouseexecutesql.go:97

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)
	}
	paramsMap := params.AsMap()
	sql, ok := paramsMap["sql"].(string)
	if !ok {
		return nil, util.NewAgentError(fmt.Sprintf("unable to cast sql parameter %s", paramsMap["sql"]), nil)
	}
	resp, err := source.RunSQL(ctx, sql, nil)
	if err != nil {
		return nil, util.ProcessGeneralError(err)
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's `source:` field to a source defined with kind `clickhouse` in the same config.
  2. Verify the source initializes successfully (its kind maps to the ClickHouse Source implementation).
  3. If you intend a custom source, make it implement the same interface (DB() *sql.DB accessor) the tool asserts.

Example fix

// before
tools:
  execute-sql:
    source: my-postgres-source
// after
tools:
  execute-sql:
    source: my-clickhouse-source
Defensive patterns

Strategy: validation

Validate before calling

// Go: before wiring the tool, assert the source is compatible
if _, ok := mySource.(sources.Source); !ok {
    return fmt.Errorf("source does not implement sources.Source")
}
// and confirm the YAML `source:` points at a clickhouse-kind source

Type guard

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

Prevention

When it happens

Trigger: Calling (or the server invoking) clickhouse-execute-sql's ValidateSource with a sources.Source that is not internal/sources/clickhouse.Source, e.g. a Postgres/BigQuery source attached to a ClickHouse tool in the tools YAML.

Common situations: YAML config where the tool's `source:` points at a differently-typed source; copying a tool config between database kinds; refactoring that renamed/moved the ClickHouse source type so the assertion no longer matches.

Related errors


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