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
This error is thrown by Tool.ValidateSource when the source instance passed to the cloudstorage-delete-bucket tool does not implement the tool's compatibleSource interface. The toolbox only allows tools to run against sources that provide the required client (e.g. a Cloud Storage-backed source with storage client). It fails fast at validation time instead of panicking later during Invoke.
Source
Thrown at internal/tools/cloudstorage/cloudstoragedeletebucket/cloudstoragedeletebucket.go:100
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()
bucket, ok := mapParams[bucketKey].(string)
if !ok || bucket == "" {
return nil, util.NewAgentError(fmt.Sprintf("invalid or missing '%s' parameter; expected a non-empty string", bucketKey), nil)
}
resp, err := source.DeleteBucket(ctx, bucket)
if err != nil {
return nil, cloudstoragecommon.ProcessGCSError(err)View on GitHub (pinned to 8cc6e09de2)
Solutions
- Set the tool's source field to the name of a cloudstorage source in tools.yaml
- Verify the referenced source kind is the Cloud Storage source that implements the tool's compatibleSource interface
- Run the toolbox and check startup logs: source type mismatch is reported at config load time
Example fix
// before
sources:
my-db:
kind: postgres
uri: ...
tools:
delete-bucket:
kind: cloudstorage-delete-bucket
source: my-db
// after
sources:
my-gcs:
kind: cloudstorage
...
tools:
delete-bucket:
kind: cloudstorage-delete-bucket
source: my-gcs Defensive patterns
Strategy: type-guard
Validate before calling
// before starting the server, check the source kind in your tools.yaml
sources := cfg.Sources
if _, ok := sources["my-gcs"].(cloudstorage.Source); !ok {
log.Fatalf("tool delete-bucket requires a cloudstorage source")
} Type guard
func isCompatibleGCSSource(s sources.Source) bool {
_, ok := s.(cloudstorage.CompatibleSource)
return ok
} Prevention
- Always pair cloudstorage tools with a cloudstorage-kind source in tools.yaml
- Run `toolbox` once locally to validate config before deploying
- Keep source names descriptive (e.g. gcs-prod) to avoid mis-binding
When it happens
Trigger: Registering the cloudstorage-delete-bucket tool in tools.yaml but binding it to a source of the wrong kind (e.g. a postgres, bigquery, or other non-cloudstorage source, or a cloudstorage source whose client is not the storage client the interface requires).
Common situations: Copy-pasting a tools.yaml where the tool's source field points at the wrong named source; renaming sources and leaving a stale reference; mixing sources from incompatible SDK versions after an upgrade.
Related errors
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
- invalid source for %q tool: source %q is not a compatible ty
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/2799927b3ec83cb9.
Report an issue: GitHub.