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-create-projectfile tool asserts that the provided sources.Source implements the tool's compatibleSource interface. If the assertion fails, the source is of an incompatible type (not a Looker source) and the tool returns this error instead of proceeding to Invoke.

Source

Thrown at internal/tools/looker/lookercreateprojectfile/lookercreateprojectfile.go:109

// 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 looker-kind source in the config
  2. Confirm the source was registered via its init() and initialized as the Looker source type
  3. In code/tests, pass a source implementing the compatibleSource interface

Example fix

# before
source: my-bigquery
tools:
  create-file:
    kind: looker-create-projectfile
# after
source: my-looker
tools:
  create-file:
    kind: looker-create-projectfile
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := src.(lookercreateprojectfile.CompatibleSource); !ok {
    return fmt.Errorf("looker-create-projectfile requires a looker source")
}

Type guard

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

Try / catch

if err := tool.ValidateSource(src); err != nil {
    if strings.Contains(err.Error(), "not a compatible type") {
        // rebind tool to the looker source
    }
    return err
}

Prevention

When it happens

Trigger: ValidateSource is called with a source whose concrete type is not a Looker source — typically because the tool's YAML source field points at a non-Looker source, or the wrong Source is passed programmatically.

Common situations: Config typo mapping a Looker tool to a database source; tests passing a mock source lacking the compatibleSource methods; sources refactored so kind strings no longer match.

Related errors


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