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

This error comes from the Dataplex tool's ValidateSource method when the sources.Source passed to the tool does not implement the tool's `compatibleSource` interface (a Go type assertion `source.(compatibleSource)` fails). Each Dataplex tool defines a narrow interface (e.g., `GenerateDataProfile(ctx, ...)`) that the configured source must satisfy; a source of the wrong kind (or a mock/stub missing the method) is rejected before Invoke runs. It is a static wiring/configuration check ensuring the tool only runs against a source capable of calling the Dataplex API.

Source

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

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

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

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's `source` in the YAML config to a Dataplex source whose implementation implements the GenerateDataProfile method required by compatibleSource.
  2. Check the compatibleSource interface at the top of internal/tools/dataplex/dataplexgeneratedataprofile/dataplexgeneratedataprofile.go and confirm your source's concrete type implements exactly that method signature.
  3. If using a custom source, add the missing method (e.g., GenerateDataProfile(ctx, ...)) with the exact signature from the interface.
  4. In tests, make the fake source embed or implement the tool's compatibleSource interface instead of only sources.Source.

Example fix

// before: tool wired to incompatible source in tools.yaml
// tools:
//   generate-profile:
//     kind: dataplex-generate-data-profile
//     source: my-postgres-source   # wrong: postgres source lacks GenerateDataProfile
//
// after
// tools:
//   generate-profile:
//     kind: dataplex-generate-data-profile
//     source: my-dataplex-source   # dataplex source implements compatibleSource
Defensive patterns

Strategy: type-guard

Validate before calling

src, ok := mySource.(interface {
	GenerateDataProfile(ctx context.Context, projectId, locationId, dataProductId, dataAssetId string) (*dataplex.DataProfileResult, error)
})
if !ok {
	return fmt.Errorf("source %T is not compatible with dataplex-generate-data-profile", mySource)
}

Type guard

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

Try / catch

if err := tool.ValidateSource(src); err != nil {
	var invalidSource *util.InvalidSourceError
	if errors.As(err, &invalidSource) {
		// fix tool/source wiring: fall back to a Dataplex source or surface config error
		return nil, fmt.Errorf("wiring: %w", err)
	}
	return nil, err
}

Prevention

When it happens

Trigger: Calling tools.ValidateSource (or the server wiring that invokes it) with a sources.Source whose concrete type does not implement the dataplexgeneratedataprofile `compatibleSource` interface, e.g., attaching a dataplex source that lacks GenerateDataProfile, a different database source entirely, or a test stub that does not implement the method set.

Common situations: YAML config wires a tool to a source of the wrong `kind`; a custom or older source implementation predates the GenerateDataProfile method; a developer's test fake implements sources.Source but not the tool's compatibleSource interface; a refactor renamed or changed the signature of GenerateDataProfile so the source no longer satisfies the interface.

Related errors


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