googleapis/mcp-toolbox · error

destination_dir cannot be empty for tool %q

Error message

destination_dir cannot be empty for tool %q

What it means

Configuration-time validation in Initialize: destination_dir is present in the tool YAML but set to an empty string, which would resolve object downloads to no directory.

Source

Thrown at internal/tools/cloudstorage/cloudstoragedownloadobject/cloudstoragedownloadobject.go:83

}

// validate interface
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)
	}
	if cfg.DestinationDir != nil {
		if *cfg.DestinationDir == "" {
			return nil, fmt.Errorf("destination_dir cannot be empty for tool %q", cfg.Name)
		}
		if _, err := cloudstoragecommon.ValidateLocalPath(*cfg.DestinationDir); err != nil {
			return nil, fmt.Errorf("destination_dir is invalid for tool %q: %w", cfg.Name, err)
		}
	}

	objectParam := parameters.NewStringParameter(objectKey, "Full object name (path) within the bucket, e.g. 'path/to/file.txt'.")
	destinationDesc := "Absolute local filesystem path where the object will be written. Relative paths and paths containing '..' are rejected."
	if cfg.DestinationDir != nil {
		destinationDesc = "Relative path under the configured destination_dir where the object will be written. Absolute paths and paths that escape destination_dir are rejected."
	}
	allParameters := parameters.Parameters{}
	if cfg.Bucket == nil {
		allParameters = append(allParameters, parameters.NewStringParameter(bucketKey, "Name of the Cloud Storage bucket containing the object."))
	}
	allParameters = append(allParameters, objectParam)
	allParameters = append(allParameters, parameters.NewStringParameter(destinationKey, destinationDesc))
	if cfg.Overwrite == nil {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Set destination_dir to a valid absolute local path
  2. Remove destination_dir to expose it as a per-call parameter
  3. Verify the env var used is set in the server process

Example fix

// before
destination_dir: ""
// after
destination_dir: /data/downloads
Defensive patterns

Strategy: validation

Validate before calling

if d, ok := toolCfg["destination_dir"]; ok && d == "" {
    return errors.New("destination_dir must be non-empty or omitted")
}

Try / catch

if err := startToolbox(); err != nil {
    if strings.Contains(err.Error(), "destination_dir cannot be empty") {
        // set a valid absolute path or drop the key
    }
    log.Fatal(err)
}

Prevention

When it happens

Trigger: destination_dir: "" or destination_dir pointing at an empty env var (e.g. ${DOWNLOAD_DIR} unset) in the tool config.

Common situations: Unset environment variable in the deployment; YAML key left blank; automated config generation emitting empty strings.

Related errors


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