googleapis/mcp-toolbox · error
bucket cannot be empty for tool %q
Error message
bucket cannot be empty for tool %q
What it means
Same validation as the get-bucket-iam-policy tool: cloudstorage-get-bucket-metadata's Initialize rejects a bucket field that is present (non-nil pointer) but an empty string. Either supply a real fixed bucket or omit the field so it becomes a tool parameter.
Source
Thrown at internal/tools/cloudstorage/cloudstoragegetbucketmetadata/cloudstoragegetbucketmetadata.go:72
tools.ConfigBase `yaml:",inline"`
Type string `yaml:"type" validate:"required"`
Source string `yaml:"source" validate:"required"`
Annotations *tools.ToolAnnotations `yaml:"annotations,omitempty"`
Bucket *string `yaml:"bucket,omitempty"`
}
var _ tools.ToolConfig = Config{}
func (cfg Config) ToolConfigType() string {
return resourceType
}
func (cfg Config) Initialize(context.Context) (tools.Tool, error) {
if cfg.Description == "" {
return nil, fmt.Errorf("description is required for tool %q", cfg.Name)
}
if cfg.Bucket != nil && *cfg.Bucket == "" {
return nil, fmt.Errorf("bucket cannot be empty for tool %q", cfg.Name)
}
allParameters := parameters.Parameters{}
if cfg.Bucket == nil {
allParameters = append(allParameters, parameters.NewStringParameter(bucketKey, "Name of the Cloud Storage bucket to inspect."))
}
return Tool{
BaseTool: tools.NewBaseTool(
cfg,
tools.GetAnnotationsOrDefault(cfg.Annotations, tools.NewReadOnlyAnnotations),
tools.Manifest{Description: cfg.Description, Parameters: allParameters.Manifest(), AuthRequired: cfg.AuthRequired},
allParameters,
),
}, nil
}
var _ tools.Tool = Tool{}View on GitHub (pinned to 8cc6e09de2)
Solutions
- Set a concrete bucket name, e.g. `bucket: my-bucket`.
- Remove the `bucket` key so the bucket becomes a required invocation-time parameter.
- Pre-validate config strings for emptiness after environment expansion.
Example fix
# before bucket: "" # after bucket: my-gcs-bucket
Defensive patterns
Strategy: validation
Validate before calling
if cfg.Bucket != nil && strings.TrimSpace(*cfg.Bucket) == "" {
return errors.New("bucket cannot be empty; set a name or omit the field")
} Type guard
func bucketProvided(cfg Config) bool { return cfg.Bucket != nil && *cfg.Bucket != "" } Prevention
- Prefer omitting `bucket` over `bucket: ""`
- Validate substituted template values before server start
- Unit-test tool Initialize with representative configs
When it happens
Trigger: cfg.Bucket != nil and *cfg.Bucket == "" at Initialize — YAML `bucket: ""` or programmatic tools.Ptr("").
Common situations: Empty env-var substitution into the bucket field; YAML key present with no value; generated configs with unset placeholders.
Related errors
- bucket cannot be empty for tool %q
- bucket cannot be empty for tool %q
- invalid source for %q tool: source %q is not a compatible ty
- description is required for tool %q
- description is required for tool %q
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/cf839e4793ef577f.
Report an issue: GitHub.