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 for looker-delete-projectdirectory asserts the supplied sources.Source implements compatibleSource (UseClientAuthorization, GetAuthTokenHeaderName, LookerApiSettings, GetLookerSDK). Non-Looker sources fail the assertion and this error is returned, preventing the tool from running against an incompatible source.

Source

Thrown at internal/tools/looker/lookerdeleteprojectdirectory/lookerdeleteprojectdirectory.go:108

// 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)
	}
	sdk, err := source.GetLookerSDK(ctx, string(accessToken))
	if err != nil {
		return nil, util.NewClientServerError("error getting sdk", http.StatusInternalServerError, err)
	}

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

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool's `source` field at a configured Looker source.
  2. Check the source's `kind` is looker and it initializes without error.
  3. For custom sources, implement the full compatibleSource interface.

Example fix

# before
source: redis-cache

# after
source: my-looker
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := src.(interface {
	UseClientAuthorization() bool
	GetAuthTokenHeaderName() string
	LookerApiSettings() *rtl.ApiSettings
	GetLookerSDK(context.Context, string) (*v4.LookerSDK, error)
}); !ok {
	return fmt.Errorf("source %T is not Looker-compatible; fix the tool's `source` field", src)
}

Type guard

func isCompatibleLookerSource(s sources.Source) bool {
	_, ok := s.(interface {
		UseClientAuthorization() bool
		GetAuthTokenHeaderName() string
		LookerApiSettings() *rtl.ApiSettings
		GetLookerSDK(context.Context, string) (*v4.LookerSDK, error)
	})
	return ok
}

Try / catch

if err := tool.ValidateSource(src); err != nil {
	return fmt.Errorf("looker-delete-projectdirectory bound to wrong source: %w", err)
}

Prevention

When it happens

Trigger: Startup tool resolution or explicit ValidateSource calls when the tool's `source` names a non-Looker source or a source missing the required SDK methods.

Common situations: Wrong source reference in YAML; source renamed/deleted and replaced with a different kind; custom source not exposing the Looker SDK.

Related errors


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