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

RequiresClientAuthorization on looker-get-project-directories returns the Looker source's client-authorization setting, but only after asserting `source.(compatibleSource)`. A non-Looker source triggers this error because authorization behavior cannot be safely queried from it.

Source

Thrown at internal/tools/looker/lookergetprojectdirectories/lookergetprojectdirectories.go:142

	if !ok {
		return nil, util.NewAgentError(fmt.Sprintf("'project_id' must be a string, got %T", mapParams["project_id"]), nil)
	}

	resp, err := lookercommon.GetProjectDirectories(sdk, projectId, source.LookerApiSettings())
	if err != nil {
		if strings.Contains(err.Error(), "status=401") {
			return nil, util.NewClientServerError("unauthorized error", http.StatusUnauthorized, err)
		}
		return nil, util.ProcessGeneralError(err)
	}

	return resp, nil
}

func (t Tool) RequiresClientAuthorization(source sources.Source) (bool, error) {
	s, ok := source.(compatibleSource)
	if !ok {
		return false, fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", t.Cfg.Type, t.Cfg.Source)
	}
	return s.UseClientAuthorization(), nil
}

func (t Tool) GetAuthTokenHeaderName(source sources.Source) (string, error) {
	s, 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 s.GetAuthTokenHeaderName(), nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool at a looker-kind source in tools.yaml.
  2. Make test doubles implement compatibleSource or embed the real source.
  3. Audit all environment configs for correct Looker source bindings.
  4. Reload/restart the toolbox after fixing bindings.

Example fix

// before
    kind: looker-get-project-directories
    source: api-gateway
// after
    kind: looker-get-project-directories
    source: my-looker
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := src.(lookercommon.CompatibleSource); !ok {
    return errors.New("looker-get-project-directories requires a looker source")
}

Type guard

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

Try / catch

requiresAuth, err := tool.RequiresClientAuthorization(src)
if err != nil {
    return false, fmt.Errorf("client auth check failed (wrong source kind?): %w", err)
}

Prevention

When it happens

Trigger: Server auth handling calls RequiresClientAuthorization for a looker-get-project-directories tool whose configured source is not a Looker source.

Common situations: Wrong source binding in tools.yaml; test mocks missing the interface; environment-specific configs (dev/staging/prod) drifting so some bind non-Looker sources.

Related errors


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