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

The looker-get-project-file tool's ValidateSource method type-asserts the supplied sources.Source to the tool's compatibleSource interface. If the source bound to this tool does not implement that interface (i.e. it is not a Looker source), the assertion fails and this error is returned before the tool ever runs. It is a wiring/config mismatch, not a runtime failure.

Source

Thrown at internal/tools/looker/lookergetprojectfile/lookergetprojectfile.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)
	}
	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. Open your toolbox YAML and set the tool's `source:` field to the name of a source declared with kind `looker`.
  2. Verify the referenced source exists under `sources:` and is of type looker (the Looker API source implements UseClientAuthorization/GetAuthTokenHeaderName).
  3. If you embed this tool in code, pass the looker source instance (lookers.Source) to the toolset/server, not another sources.Source implementation.

Example fix

// before (tools.yaml)
tools:
  get-project-file:
    kind: looker-get-project-file
    source: my-postgres   # wrong source
// after
tools:
  get-project-file:
    kind: looker-get-project-file
    source: my-looker     # a looker-kind source
Defensive patterns

Strategy: type-guard

Validate before calling

// Before building the toolset, check each tool's declared source kind
for name, toolCfg := range cfg.Tools {
    src, ok := cfg.Sources[toolCfg.Source]
    if !ok {
        return fmt.Errorf("tool %q references unknown source %q", name, toolCfg.Source)
    }
    if _, isLooker := src.(*lookers.Source); !isLooker {
        return fmt.Errorf("tool %q needs a looker source, got %T", name, src)
    }
}

Type guard

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

Try / catch

if err := tool.ValidateSource(src); err != nil {
    return fmt.Errorf("looker tool source binding invalid, fix the 'source:' field in tools.yaml: %w", err)
}

Prevention

When it happens

Trigger: Calling ValidateSource (directly or via server/toolset startup) with a source whose concrete Go type does not satisfy lookergetprojectfile.compatibleSource; e.g. a tool YAML entry sets `source: my-source` where my-source is a postgres/bigquery/http source rather than a Looker source.

Common situations: Copy-pasting a tools.yaml and forgetting to change the `source:` field to the Looker source name; renaming the Looker source in the sources section without updating the tool's source reference so it resolves to another source; mixing sources in a toolset where a Looker tool is attached to a non-Looker source.

Related errors


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