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

ValidateSource() type-asserts the provided sources.Source to the tool's compatibleSource interface. AlloyDB wait-for-operation only works with sources implementing its required methods (long-running operation polling against AlloyDB Admin API); any other source type fails validation with this message naming the tool type and configured source name.

Source

Thrown at internal/tools/alloydb/alloydbwaitforoperation/alloydbwaitforoperation.go:194

	// Polling configuration
	Delay      time.Duration
	MaxDelay   time.Duration
	Multiplier float64
	MaxRetries int
}

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
}

// Invoke executes the tool's logic.
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()

	project, ok := paramsMap["project"].(string)
	if !ok {
		return nil, util.NewAgentError("missing 'project' parameter", nil)
	}
	location, ok := paramsMap["location"].(string)
	if !ok {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set the tool's source field to an AlloyDB (alloydb-admin style) source that implements the required interface.
  2. Check the source definition in the sources: section of your config and confirm its type matches what this tool expects.
  3. If you meant a different database, use the equivalent wait-for-operation tool for that source instead.

Example fix

// before
sources:
  my-alloydb:
    kind: postgres
tools:
  wait-op:
    kind: alloydb-wait-for-operation
    source: my-alloydb
// after
sources:
  my-alloydb:
    kind: alloydb-admin
tools:
  wait-op:
    kind: alloydb-wait-for-operation
    source: my-alloydb
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := src.(sources.Source); !ok {
    return errors.New("value does not implement sources.Source")
}
// before attaching the tool, check the source kind in your config matches alloydb

Type guard

cs, ok := src.(alloydbwaitforoperation.CompatibleSource)
if !ok {
    return fmt.Errorf("source %T is not compatible with alloydb-wait-for-operation", src)
}

Try / catch

if err := tool.ValidateSource(src); err != nil {
    log.Fatalf("tool/source mismatch: %v", err)
}

Prevention

When it happens

Trigger: Attaching the alloydb-wait-for-operation tool to a source that does not implement compatibleSource — e.g. a postgres, cloud-sql, or storage source — either in YAML by pointing the tool's source field at an incompatible source, or programmatically by passing a wrong Source to ValidateSource.

Common situations: Copy-pasting a tool block between prebuilt configs and leaving the source pointing at the wrong database; renaming sources so the tool binds to the wrong one; mixing AlloyDB Admin tools with plain Postgres sources.

Related errors


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