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

Trino SQL tools only work with sources that implement the compatibleSource interface (a Trino-compatible DB source). ValidateSource does a Go type assertion on the provided source and returns this error if it fails, preventing a tool from being paired with an incompatible source in the toolbox config.

Source

Thrown at internal/tools/trino/trinosql/trinosql.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 {
		return nil, util.NewAgentError("unable to extract standard params", err)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's 'source' field to a source defined with kind trino in the same tools.yaml
  2. Check the source's kind under internal/sources to confirm it implements the Trino compatibleSource interface
  3. Rebuild/restart toolbox and verify with the /mcp or tool list endpoint that the tool-source pairing loads

Example fix

# before
sources:
  my-pg:
    kind: postgres
    uri: postgres://...
tools:
  run-trino-sql:
    kind: trino-execute-sql
    source: my-pg
# after
sources:
  my-trino:
    kind: trino
    host: trino.example.com
    port: 8080
tools:
  run-trino-sql:
    kind: trino-execute-sql
    source: my-trino
Defensive patterns

Strategy: validation

Validate before calling

// before starting toolbox, check pairing
kind, _ := getSourceKind(toolsYAML, tool.Source)
if kind != "trino" {
    return fmt.Errorf("tool %s requires a trino source, got %s", tool.Name, kind)
}

Type guard

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

Prevention

When it happens

Trigger: Configuring a tool of type trino-sql whose 'source' field points at a source of a different kind (e.g. postgres, alloydb, cloud-sql-postgres) instead of a Trino source; also when Invoke/ValidateSource receives a source that doesn't implement compatibleSource.

Common situations: Copy-pasting a prebuilt config and forgetting to change the source name; wiring tools to the wrong source kind in tools.yaml; renaming sources so the tool binds to a leftover incompatible source.

Related errors


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