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

In the cloud-sql-get-instances tool, resolveParams asserts the source to the tool's compatibleSource interface to read the source's default GCP project; a failed assertion yields this error. It indicates the tool is paired with a source kind that does not implement the Cloud SQL Admin surface (GetDefaultProject) required to resolve its parameters. It is a setup-time source/tool compatibility failure, not a GCP API error.

Source

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

// buildParams builds the tool's parameters. A non-empty project means the source has a
// configured default project, which is baked into the project param; otherwise the plain form is used.
func buildParams(project string) parameters.Parameters {
	projectParam := parameters.NewStringParameter("projectId", "The project ID")
	if project != "" {
		projectParam = parameters.NewStringParameter("projectId", "The GCP project ID. This is pre-configured; do not ask for it unless the user explicitly provides a different one.", parameters.WithStringDefault(project))
	}
	return parameters.Parameters{
		projectParam,
		parameters.NewStringParameter("instanceId", "The instance ID"),
	}
}

// resolveParams builds the tool's parameters using the source's configured default GCP project.
func (t Tool) resolveParams(source sources.Source) (parameters.Parameters, error) {
	s, ok := source.(compatibleSource)
	if !ok {
		return nil, fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", t.Cfg.Type, t.Cfg.Source)
	}
	return buildParams(s.GetDefaultProject()), nil
}

// GetParameters returns the tool's parameters, resolved against the source.
func (t Tool) GetParameters(source sources.Source) (parameters.Parameters, error) {
	return t.resolveParams(source)
}

// Manifest returns the tool's manifest, resolved against the source.
func (t Tool) Manifest(source sources.Source) (tools.Manifest, error) {
	allParameters, err := t.resolveParams(source)
	if err != nil {
		return tools.Manifest{}, err
	}
	return tools.Manifest{Description: t.Cfg.Description, Parameters: allParameters.Manifest(), AuthRequired: t.Cfg.AuthRequired}, nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Point the tool at a Cloud SQL Admin-compatible source in tools.yaml.
  2. Add GetDefaultProject() string (and the rest of compatibleSource) to any custom source implementation.
  3. Upgrade source and tool packages in lockstep to avoid interface drift.
  4. Call ValidateSource before GetParameters in custom initialization to catch the mismatch.
  5. Debug with fmt.Printf("%T", src) to confirm the concrete source type.

Example fix

// before
getInstances.GetParameters(myPostgresSource) // incompatible
// after
getInstances.GetParameters(cloudSQLAdminSource) // implements compatibleSource
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Try / catch

params, err := tool.GetParameters(src)
if err != nil {
	log.Printf("wrong source bound to cloud-sql-get-instances: %v", err)
	return err
}

Prevention

When it happens

Trigger: GetParameters(source) on the cloudsqlgetinstances tool with a source that fails the source.(compatibleSource) assertion — e.g. during server startup or MCP tool listing when the config maps cloud-sql-get-instances to a postgres/mysql/bigquery source instead of a Cloud SQL Admin source.

Common situations: Typically a tools.yaml misconfiguration (tool pointing at the wrong source), a custom source not implementing GetDefaultProject() string, or interface changes after upgrading only one of the source/tool packages.

Related errors


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