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 on the looker-health-analyze tool type-asserts the provided sources.Source to the tool's compatibleSource interface; if the assertion fails it returns this error. It exists so the server can verify at bind/validation time that a tool's source is usable by the tool. Any non-Looker source triggers it.

Source

Thrown at internal/tools/looker/lookerhealthanalyze/lookerhealthanalyze.go:122

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. Point the tool's source field at a Looker source in tools.yaml.
  2. Ensure the source implements all methods of the compatibleSource interface.
  3. Rebuild/reload the toolbox so validation runs against the corrected sources.
  4. Add a unit test calling ValidateSource with your source to catch regressions.

Example fix

// before
tool.ValidateSource(genericHTTPSource{})
// after
if _, ok := genericHTTPSource{}.(looker.CompatibleSource); !ok {
    tool.ValidateSource(lookerSource) // use a source implementing compatibleSource
}
Defensive patterns

Strategy: validation

Validate before calling

if err := tool.ValidateSource(src); err != nil {
    return fmt.Errorf("source %T incompatible with looker-health-analyze: %w", src, err)
}

Type guard

func isCompatibleLookerSource(s sources.Source) bool {
    _, ok := s.(interface {
        UseClientAuthorization() bool
        GetAuthTokenHeaderName() string
    })
    return ok
}

Try / catch

if err := tool.ValidateSource(src); err != nil {
    if strings.Contains(err.Error(), "not a compatible type") {
        return fmt.Errorf("bind tool to a looker source, got %T", src)
    }
    return err
}

Prevention

When it happens

Trigger: Calling ValidateSource with a source that does not implement compatibleSource — typically when a tool in tools.yaml references a source of the wrong kind, or when server code passes the wrong Source to the tool.

Common situations: Misconfigured tools.yaml mapping the tool to a non-Looker source, duplicated source names with different kinds, or code refactors that changed source types without updating tool bindings.

Related errors


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