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

dataplex-search-aspect-types validates that its attached source implements its compatibleSource interface (SearchAspectTypes method). ValidateSource returns this error for any other source type. This is a tool-to-source wiring check at configuration/startup time.

Source

Thrown at internal/tools/dataplex/dataplexsearchaspecttypes/dataplexsearchaspecttypes.go:98

// 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)
	}
	paramsMap := params.AsMap()
	query, ok := paramsMap["query"].(string)
	if !ok {
		return nil, util.NewAgentError(fmt.Sprintf("error casting 'query' parameter: %v", paramsMap["query"]), nil)
	}
	pageSize, ok := paramsMap["pageSize"].(int)
	if !ok {
		return nil, util.NewAgentError(fmt.Sprintf("error casting 'pageSize' parameter: %v", paramsMap["pageSize"]), nil)
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Attach a dataplex source to the tool in the YAML config
  2. Check tool startup validation logs for the failing binding
  3. Recreate the tool block pointing at the Dataplex source

Example fix

// before
source: postgres
// after
source: dataplex
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := src.(interface {
	SearchAspectTypes(ctx context.Context, query string, pageSize int32) (*dataplex.GoogleCloudDataplexV1SearchAspectTypesResponse, error)
}); !ok {
	return fmt.Errorf("source %T does not support SearchAspectTypes", src)
}

Type guard

func isDataplexSearchAspectTypesSource(s sources.Source) bool {
	_, ok := s.(interface {
		SearchAspectTypes(ctx context.Context, query string, pageSize int32) (*dataplex.GoogleCloudDataplexV1SearchAspectTypesResponse, error)
	})
	return ok
}

Try / catch

if err := tool.ValidateSource(src); err != nil {
	// incompatible source: fix the tool->source binding in config
	return fmt.Errorf("invalid tool source: %w", err)
}

Prevention

When it happens

Trigger: Calling ValidateSource with a sources.Source that does not implement compatibleSource (SearchAspectTypes(ctx, query, pageSize)).

Common situations: Tool config bound to a wrong source kind; source renamed or replaced with a non-Dataplex source during refactoring.

Related errors


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