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

tidb-execute-sql's ValidateSource asserts the bound source implements compatibleSource (a TiDB/MySQL-compatible source). Binding the tool to any other source kind fails the assertion and produces this error, keeping tools and sources engine-matched.

Source

Thrown at internal/tools/tidb/tidbexecutesql/tidbexecutesql.go:126

	resp, err := source.RunSQL(ctx, sqlStr, nil)
	if err != nil {
		return nil, util.ProcessGeneralError(err)
	}
	return resp, 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. Point `source:` at a source with the TiDB kind.
  2. Declare the TiDB source under `sources:` if absent.
  3. Validate source kind per tool at startup.

Example fix

# before
source: my-postgres
# after
source: my-tidb
Defensive patterns

Strategy: type-guard

Validate before calling

yq '.tools[] | select(.kind == "tidb-execute-sql") | .source' tools.yaml
# verify the named source has the TiDB kind

Type guard

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

Try / catch

if err := tool.ValidateSource(src); err != nil {
    return fmt.Errorf("%w (tool requires a tidb source)", err)
}

Prevention

When it happens

Trigger: `tidb-execute-sql` tool's `source:` names a non-TiDB source; Invoke called directly with an incompatible sources.Source.

Common situations: Sharing a config across TiDB and MySQL setups and pointing at the wrong source; renaming sources during refactors.

Related errors


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