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

ValidateSource checks that the source passed to the looker-update-agent tool implements its compatibleSource interface. A failed type assertion means the bound source is not a Looker source, so Invoke could never safely call Looker APIs; the error short-circuits with a formatted message naming the tool config type and source name.

Source

Thrown at internal/tools/looker/lookerupdateagent/lookerupdateagent.go:126

// 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)
	}
	logger, err := util.LoggerFromContext(ctx)
	if err != nil {
		return nil, util.NewClientServerError("unable to get logger from ctx", http.StatusInternalServerError, err)
	}

	sdk, err := source.GetLookerSDK(ctx, string(accessToken))
	if err != nil {
		return nil, util.NewClientServerError(fmt.Sprintf("error getting sdk: %v", err), http.StatusInternalServerError, err)
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's `source` to the Looker source name in your config
  2. Check startup logs to confirm the referenced source initialized as kind looker
  3. If composing programmatically, pass the correct sources.Source (looker source) to ValidateSource

Example fix

// before
tools:
  update_agent:
    kind: looker-update-agent
    source: my-bigquery-source
// after
tools:
  update_agent:
    kind: looker-update-agent
    source: my-looker-source
Defensive patterns

Strategy: type-guard

Validate before calling

if err := tool.ValidateSource(lookerSource); err != nil {
    return fmt.Errorf("bind check failed: %w", err)
}

Type guard

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

Try / catch

if err := tool.ValidateSource(src); err != nil {
    if strings.Contains(err.Error(), "not a compatible type") {
        // fix the tool's source binding, then retry
    }
    return err
}

Prevention

When it happens

Trigger: Tool.ValidateSource is called during server init (tool-source binding validation) or pre-invoke, with a source that is not the Looker source implementation — typically a misnamed `source:` reference in the tool config.

Common situations: Tool bound to a wrong-kind source (e.g. postgres, http) in tools.yaml; source renamed/removed so binding resolution picks an incorrect source; wiring tools programmatically with the wrong sources.Source instance.

Related errors


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