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

YugabyteDB SQL tools only accept sources implementing compatibleSource (a database/sql-backed YugabyteDB source). ValidateSource's type assertion failing produces this error, blocking tool execution against a wrong-kind source.

Source

Thrown at internal/tools/yugabytedbsql/yugabytedbsql.go:106

// validate interface
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 {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's source to a kind: yugabytedb source in tools.yaml
  2. Fix the source kind if it was accidentally declared as postgres or another kind
  3. Verify the source name referenced by the tool exists and matches the intended source

Example fix

# before
sources:
  yb:
    kind: postgres
tools:
  yb-sql:
    kind: yugabytedb-execute-sql
    source: yb
# after
sources:
  yb:
    kind: yugabytedb
    host: yb.example.com
    port: 5433
tools:
  yb-sql:
    kind: yugabytedb-execute-sql
    source: yb
Defensive patterns

Strategy: validation

Validate before calling

kind, _ := getSourceKind(toolsYAML, tool.Source)
if kind != "yugabytedb" {
    return fmt.Errorf("tool %s requires a yugabytedb source, got %s", tool.Name, kind)
}

Type guard

func asYugabyteSource(s sources.Source) (compatibleSource, bool) {
    cs, ok := s.(compatibleSource)
    return cs, ok
}

Try / catch

if err := tool.ValidateSource(src); err != nil {
    // rebind tool to a kind: yugabytedb source and reload
}

Prevention

When it happens

Trigger: Pairing a yugabytedbsql tool with a source of another kind (e.g. postgres) in tools.yaml; calling ValidateSource/Invoke with a sources.Source that doesn't implement compatibleSource.

Common situations: YugabyteDB being Postgres-wire-compatible leads users to reuse postgres sources; copy-pasted prebuilt configs with unchanged source references; kind typos in the source definition.

Related errors


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