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

Identical source-compatibility guard as mongodb-delete-one: mongodbfind.Tool.ValidateSource asserts the provided source implements the MongoDB compatibleSource interface. Any non-MongoDB source bound to a mongodb-find tool produces this error with the tool type and configured source name.

Source

Thrown at internal/tools/mongodb/mongodbfind/mongodbfind.go:132

// 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 getOptions(ctx context.Context, sortParameters parameters.Parameters, projectPayload string, limit int64, paramsMap map[string]any) (*options.FindOptionsBuilder, error) {
	logger, err := util.LoggerFromContext(ctx)
	if err != nil {
		return nil, err
	}

	opts := options.Find()

	sort := bson.M{}
	for _, p := range sortParameters {
		sort[p.GetName()] = paramsMap[p.GetName()]
	}
	opts = opts.SetSort(sort)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool's source at a MongoDB-based source kind.
  2. Verify the source name exists and its kind is MongoDB-compatible.
  3. Programmatic usage: pass the MongoDB source instance, not another engine's.

Example fix

# before
  find:
    kind: mongodb-find
    source: my-mysql
# after
  find:
    kind: mongodb-find
    source: my-mongo
Defensive patterns

Strategy: type-guard

Validate before calling

if err := tool.ValidateSource(src); err != nil { /* fix tools.yaml source binding */ }

Type guard

func isMongoSource(s sources.Source) bool {
    type mongoSrc interface{ SourceType() string }
    if m, ok := s.(mongoSrc); ok {
        t := m.SourceType()
        return t == "mongodb" || t == "mongodb-atlas"
    }
    return false
}

Try / catch

if err := t.ValidateSource(src); err != nil {
    return fmt.Errorf("mongodb-find bound to non-Mongo source %q: %w", srcName, err)
}

Prevention

When it happens

Trigger: A mongodb-find tool referencing a postgres/mysql/mssql or other non-MongoDB source in tools.yaml; passing a wrong sources.Source implementation at runtime.

Common situations: Reusing a tool block across configs with the old source name; switching a source's kind without updating tools; source-name typos resolving to another source.

Related errors


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