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

Tool.ValidateSource for mongodb-delete-many rejects sources that do not implement the MongoDB compatibleSource interface. The tool needs a Mongo client from the source to delete documents; an incompatible source type cannot supply one, so the mismatch fails validation.

Source

Thrown at internal/tools/mongodb/mongodbdeletemany/mongodbdeletemany.go:121

// 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()

	collection, tbErr := mongodbcommon.ResolveCollection(t.Cfg.Collection, paramsMap)
	if tbErr != nil {
		return nil, tbErr
	}

	filterString, err := parameters.PopulateTemplateWithJSON("MongoDBDeleteManyFilter", t.Cfg.FilterPayload, paramsMap)
	if err != nil {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's `source` to a `mongodb` kind source
  2. Check that the referenced source name exists under `sources:`
  3. Run a local config validation/start before deploying

Example fix

// before
delete-many:
  kind: mongodb-delete-many
  source: my-mysql
// after
delete-many:
  kind: mongodb-delete-many
  source: my-mongodb
Defensive patterns

Strategy: validation

Validate before calling

if err := deleteManyTool.ValidateSource(src); err != nil {
    return fmt.Errorf("mongodb-delete-many %q: %w", name, err)
}

Prevention

When it happens

Trigger: Attaching mongodb-delete-many to a non-MongoDB source in tools.yaml; the server invokes ValidateSource for each tool/source pair at startup.

Common situations: Tool `source` field pointing at the wrong named source; source kind swapped (e.g. from mongodb to firestore); copy-paste across tool blocks.

Related errors


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