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 checks that the injected source implements the tool's compatibleSource interface (the Trino source). If the source is any other type, this error is returned with the tool's type and configured source name. Each tool only works with sources of its matching engine kind.

Source

Thrown at internal/tools/trino/trinoexecutesql/trinoexecutesql.go:101

// 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)
	}

	sliceParams := params.AsSlice()
	sql, ok := sliceParams[0].(string)
	if !ok {
		return nil, util.NewAgentError("unable to cast the `sql` input parameter into string", nil)
	}
	res, err := source.RunSQL(ctx, sql, []any{})
	if err != nil {
		return nil, util.ProcessGeneralError(err)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Change the tool's `source:` to reference a source of kind trino
  2. Verify the referenced source's kind in the sources section matches the tool's engine
  3. If using a custom source, ensure it implements the Trino source's compatibleSource interface

Example fix

// before (tools.yaml)
run_query:
  kind: trino-execute-sql
  source: my-postgres
// after
run_query:
  kind: trino-execute-sql
  source: my-trino
Defensive patterns

Strategy: type-guard

Validate before calling

if sourceKindOf[tool.Source] != "trino" {
    return fmt.Errorf("trino-execute-sql requires a trino source, got %q", sourceKindOf[tool.Source])
}

Type guard

func isTrinoSource(s sources.Source) bool {
    _, ok := s.(trinosource.Source) // satisfies trinoexecutesql's compatibleSource
    return ok
}

Try / catch

if err := tool.ValidateSource(src); err != nil {
    return fmt.Errorf("repoint the tool's source to a trino source: %w", err)
}

Prevention

When it happens

Trigger: Calling ValidateSource (or Invoke via the server after source resolution) on a trino-execute-sql Tool with a sources.Source that is not a Trino source — i.e. the tool's `source:` points at a non-Trino source.

Common situations: Pointing a trino-execute-sql tool at a Postgres/MySQL/other source by mistake; a custom source implementation that doesn't satisfy the Trino compatibleSource interface; copy-pasting a tool entry and forgetting to change the source.

Related errors


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