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` performs a type assertion of the provided sources.Source to the tool's `compatibleSource` interface. Any source that is not a Looker source fails the assertion and produces this error, blocking tool invocation.

Source

Thrown at internal/tools/looker/lookergetconnections/lookergetconnections.go:105

// 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("error getting sdk", 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. Confirm the source kind is `looker` in the sources section of the config
  3. If using a custom source, implement the compatibleSource methods (UseClientAuthorization, GetAuthTokenHeaderName, API client access)
  4. Run the server and read the startup validation error to find which tool/source pair mismatched

Example fix

// before
sources:
  src:
    kind: postgres
    uri: postgres://...
tools:
  conns:
    kind: looker-get-connections
    source: src
// after
sources:
  src:
    kind: looker
    baseUrl: https://my.looker.com
    clientId: ...
    clientSecret: ...
tools:
  conns:
    kind: looker-get-connections
    source: src
Defensive patterns

Strategy: type-guard

Validate before calling

if err := tool.ValidateSource(src); err != nil {
    return fmt.Errorf("tool/source mismatch: %w", err)
}

Type guard

func isLookerSource(s sources.Source) bool {
    _, ok := s.(lookergetconnections.CompatibleSource)
    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 Tool.ValidateSource (or the Invoke path that follows it) with a source that does not implement compatibleSource — usually a mis-wired `source:` reference in the tool config.

Common situations: tools.yaml points the tool at a non-Looker source; server startup assigns tools to sources by name and the names were swapped; custom source implementations added without implementing compatibleSource.

Related errors


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