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

Same guard as error 1420 but in firestore-get-documents: ValidateSource asserts the supplied source implements compatibleSource. A non-Firestore source fails the assertion and returns this wrapped error before invocation.

Source

Thrown at internal/tools/firestore/firestoregetdocuments/firestoregetdocuments.go:103

// 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)
	}
	mapParams := params.AsMap()
	documentPathsRaw, ok := mapParams[documentPathsKey].([]any)
	if !ok {
		return nil, util.NewAgentError(fmt.Sprintf("invalid or missing '%s' parameter; expected an array", documentPathsKey), nil)
	}

	if len(documentPathsRaw) == 0 {
		return nil, util.NewAgentError(fmt.Sprintf("'%s' parameter cannot be empty", documentPathsKey), nil)
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool's `source:` at a firestore-kind source in the config.
  2. Ensure the source is initialized successfully (kind: firestore) before tool creation.
  3. Pass the correct source instance when calling ValidateSource programmatically.

Example fix

// before
source: my-sql
tools:
  get_docs:
    kind: firestore-get-documents
    source: my-sql
// after
sources:
  my-fs:
    kind: firestore
    project: my-project
tools:
  get_docs:
    kind: firestore-get-documents
    source: my-fs
Defensive patterns

Strategy: type-guard

Validate before calling

if err := tool.ValidateSource(mySource); err != nil {
	return fmt.Errorf("firestore-get-documents bound to wrong source: %w", err)
}

Type guard

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

Try / catch

if err := tool.ValidateSource(src); err != nil {
	return fmt.Errorf("invalid binding for %s: %w", toolName, err)
}

Prevention

When it happens

Trigger: Resolving or invoking the tool with a sources.Source whose concrete type is not the Firestore source.

Common situations: Config where the tool's source name refers to a non-firestore source; swapping a tool definition to a new source kind without revalidating.

Related errors


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