googleapis/mcp-toolbox · error

unable to access config folder at %q: %w

Error message

unable to access config folder at %q: %w

What it means

GetPathsFromConfigFolder stats the given folder path before globbing for YAML files. If os.Stat fails (missing path, permission denied, broken symlink), the error is wrapped with the folder path.

Source

Thrown at cmd/internal/config.go:539

	if len(configs) == 0 {
		return Config{}, fmt.Errorf("no YAML files found")
	}
	if len(configs) > 1 {
		mergedFile, err := mergeConfigs(configs...)
		if err != nil {
			return Config{}, fmt.Errorf("unable to merge config files: %w", err)
		}
		return mergedFile, nil
	}
	return configs[0], nil
}

// GetPathsFromConfigFolder loads all YAML files from a directory and merges them
func GetPathsFromConfigFolder(ctx context.Context, folderPath string) ([]string, error) {
	// Check if directory exists
	info, err := os.Stat(folderPath)
	if err != nil {
		return nil, fmt.Errorf("unable to access config folder at %q: %w", folderPath, err)
	}
	if !info.IsDir() {
		return nil, fmt.Errorf("path %q is not a directory", folderPath)
	}

	// Find all YAML files in the directory
	pattern := filepath.Join(folderPath, "*.yaml")
	yamlFiles, err := filepath.Glob(pattern)
	if err != nil {
		return nil, fmt.Errorf("error finding YAML files in %q: %w", folderPath, err)
	}

	// Also find .yml files
	ymlPattern := filepath.Join(folderPath, "*.yml")
	ymlFiles, err := filepath.Glob(ymlPattern)
	if err != nil {
		return nil, fmt.Errorf("error finding YML files in %q: %w", folderPath, err)
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Verify the folder exists at the given path
  2. Use an absolute path for --config-folder
  3. Fix permissions or mount the directory into the container

Example fix

// before
toolbox --config-folder ./myconfigs   # does not exist
// after
mkdir -p ./myconfigs && toolbox --config-folder ./myconfigs
Defensive patterns

Strategy: try-catch

Validate before calling

if info, err := os.Stat(folder); err != nil {
  return fmt.Errorf("config folder %q inaccessible: %w", folder, err)
}

Try / catch

paths, err := GetPathsFromConfigFolder(ctx, folder)
if err != nil {
  var pe *fs.PathError
  if errors.As(err, &pe) {
    log.Printf("cannot access folder %s: %v", pe.Path, pe.Err)
  }
  return err
}

Prevention

When it happens

Trigger: os.Stat(folderPath) fails when calling GetPathsFromConfigFolder with a --config-folder argument that does not exist or is not accessible.

Common situations: Typo in the --config-folder path; directory not mounted in a container; relative path resolved from an unexpected working directory; permission restrictions.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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