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 for the cloud-sql-list-databases tool returns this error when the provided source does not satisfy the tool's compatibleSource interface, meaning the tool cannot operate on that source. The toolbox requires each Cloud SQL Admin tool's source to expose the Admin-API surface (project, client-authorization flag, list-databases operation). The error signals a config-level tool/source type mismatch that must be fixed before invocation.

Source

Thrown at internal/tools/cloudsql/cloudsqllistdatabases/cloudsqllistdatabases.go:100

}

// Tool represents the list-databases 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
}

// 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)
	}
	instance, ok := paramsMap["instance"].(string)
	if !ok {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Ensure tools.yaml binds the tool to a Cloud SQL Admin-compatible source kind.
  2. Complete compatibleSource implementation (GetDefaultProject, UseClientAuthorization, ListDatabases) on custom sources.
  3. Upgrade source/tool packages together so interfaces match.
  4. Call ValidateSource early in custom initialization to fail fast.
  5. Verify the source's concrete type via %T before wiring it.

Example fix

// before
listDatabases.ValidateSource(alloydbAdminSource) // incompatible
// after
listDatabases.ValidateSource(cloudsqlAdminSource) // implements compatibleSource
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := src.(compatibleSource); !ok {
	return fmt.Errorf("source %T incompatible with cloud-sql-list-databases", src)
}

Type guard

func isListDatabasesSource(s sources.Source) bool {
	_, ok := s.(interface {
		GetDefaultProject() string
		UseClientAuthorization() bool
	})
	return ok
}

Try / catch

if err := tool.ValidateSource(src); err != nil {
	return fmt.Errorf("bad source binding for cloud-sql-list-databases: %w", err)
}

Prevention

When it happens

Trigger: ValidateSource(source) (and the startup validation path that calls it) with a sources.Source that fails source.(compatibleSource) — for example pairing cloud-sql-list-databases with a postgres connection source or an alloydb admin source that does not implement ListDatabases/GetDefaultProject/UseClientAuthorization.

Common situations: Wrong source name in tools.yaml; a custom Cloud SQL source that lacks the newest interface methods after a toolbox upgrade; test harnesses passing partial mock sources.

Related errors


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