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

cloudsqlpg-upgrade-precheck asserts the bound source to its compatibleSource interface during ValidateSource. Only Cloud SQL Postgres sources support the pre-check LRO; any other source fails validation with this message before Invoke ever runs.

Source

Thrown at internal/tools/cloudsqlpg/cloudsqlpgupgradeprecheck/cloudsqlpgupgradeprecheck.go:136

			MessageType:     item.MessageType,
			ActionsRequired: item.ActionsRequired,
		}
	}
	return results
}

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 || project == "" {
		return nil, util.NewAgentError("missing or empty 'project' parameter", nil)
	}
	instanceName, ok := paramsMap["instance"].(string)
	if !ok || instanceName == "" {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Configure the tool with a `cloud-sql-postgres` source (instance under Cloud SQL Admin control)
  2. Verify the source kind and name in the YAML; restart toolbox
  3. Use the Cloud SQL API directly for non-CloudSQL instances — this tool cannot pre-check them

Example fix

// before
sources:
  pg:
    kind: postgres
tools:
  precheck:
    kind: cloud-sql-pg-upgrade-precheck
    source: pg
// after
sources:
  pg:
    kind: cloud-sql-postgres
    project: my-project
    instance: my-instance
tools:
  precheck:
    kind: cloud-sql-pg-upgrade-precheck
    source: pg
Defensive patterns

Strategy: validation

Validate before calling

if err := tool.ValidateSource(src); err != nil { return fmt.Errorf("upgrade-precheck requires a cloud-sql-postgres source: %w", err) }

Type guard

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

Try / catch

if err := tool.ValidateSource(src); err != nil {
    return nil // skip precheck tool registration rather than crash
}

Prevention

When it happens

Trigger: Tool validation at startup when `source.(compatibleSource)` fails — tool's source field references a non-cloud-sql-postgres source (vanilla postgres, alloydb, etc.).

Common situations: Trying to run major-version upgrade pre-checks against a self-managed postgres; copying the tool into a config where the source is a plain database source.

Related errors


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