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

clickhouse-sql.ValidateSource type-asserts the given sources.Source against the tool's private `compatibleSource` interface (ClickHouse source with a *sql.DB accessor) and returns this error on mismatch. It is the toolbox's mechanism to keep tools and sources of matching kinds wired together.

Source

Thrown at internal/tools/clickhouse/clickhousesql/clickhousesql.go:103

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()
	newStatement, err := parameters.ResolveTemplateParams(t.Cfg.TemplateParameters, t.Cfg.Statement, paramsMap)
	if err != nil {
		return nil, util.NewAgentError("unable to extract template params", err)
	}

	newParams, err := parameters.GetParams(t.Cfg.Parameters, paramsMap)
	if err != nil {
		return nil, util.NewAgentError("unable to extract standard params", err)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's `source:` to a clickhouse-kind source.
  2. Double-check source name spelling and that it is defined in `sources:`.
  3. Implement the compatibleSource interface if using a custom source.
Defensive patterns

Strategy: validation

Validate before calling

// Fail fast at server startup
for _, t := range loadedTools {
    if err := t.Tool.ValidateSource(t.Source); err != nil {
        return fmt.Errorf("tool %q: %w", t.Tool.GetName(), err)
    }
}

Type guard

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

Prevention

When it happens

Trigger: Binding clickhouse-sql to any non-ClickHouse source — a wrong `source:` name in YAML resolving to another kind, or passing an incompatible source programmatically/in tests.

Common situations: Copy-pasting tool configs across database examples; multiple sources defined and the wrong one referenced; custom source implementations missing the expected accessor.

Related errors


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