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 dataplexgetdiscoveryresults tool's ValidateSource returns this error when a type assertion of the supplied source to the tool's `compatibleSource` interface (GetDiscoveryResults method) fails. The tool only works with sources that can retrieve Dataplex discovery scan results, so incompatible sources are rejected at validation. It signals miswiring between the tool config and the source registry, not a Dataplex-side problem.

Source

Thrown at internal/tools/dataplex/dataplexgetdiscoveryresults/dataplexgetdiscoveryresults.go:99

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()
	scanId, _ := paramsMap["scanId"].(string)
	location, _ := paramsMap["location"].(string)

	if scanId == "" {
		return nil, util.NewAgentError("scanId parameter is required", nil)
	}
	if location == "" {
		return nil, util.NewAgentError("location parameter is required", nil)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's `source` to a Dataplex source implementing GetDiscoveryResults.
  2. Check your source's method set against compatibleSource in internal/tools/dataplex/dataplexgetdiscoveryresults/dataplexgetdiscoveryresults.go.
  3. Add GetDiscoveryResults with the exact interface signature to custom sources.
  4. Add a compile-time check `var _ compatibleSource = (*MySource)(nil)` in the source package.

Example fix

// before: fake in test
// type src struct{} // implements sources.Source only
//
// after
// type src struct{}
// func (src) GetDiscoveryResults(ctx context.Context, locationId, datascansId string) (*dataplex.DataSource, error) { ... }
Defensive patterns

Strategy: type-guard

Validate before calling

var _ interface {
	GetDiscoveryResults(ctx context.Context, /* params */) (*dataplex.DataSource, error)
} = (*myDataplexSource)(nil)

Type guard

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

Try / catch

if err := tool.ValidateSource(src); err != nil {
	if strings.Contains(err.Error(), "not a compatible type") {
		return nil, fmt.Errorf("tool %q requires a dataplex source implementing GetDiscoveryResults", toolName)
	}
	return nil, err
}

Prevention

When it happens

Trigger: Calling ValidateSource with a source missing GetDiscoveryResults — for example, after binding the tool to a different source kind in tools.yaml, or constructing a Tool with a Config referencing a source that never implemented the discovery method.

Common situations: Wrong `source:` value in the tool YAML; custom source integrations missing the method; interface drift after API signature changes; test doubles that don't implement the tool-specific interface.

Related errors


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