googleapis/mcp-toolbox · error

path %q is not a directory

Error message

path %q is not a directory

What it means

After confirming the path exists, GetPathsFromConfigFolder requires it to be a directory. If info.IsDir() is false — i.e. the user passed a file path as a config folder — this error is thrown.

Source

Thrown at cmd/internal/config.go:542

	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)
	}

	// Combine both file lists
	allFiles := append(yamlFiles, ymlFiles...)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Pass a directory containing *.yaml files to --config-folder
  2. If you meant a single file, use --config-file instead
  3. Fix symlinks that resolve to files rather than directories

Example fix

// before
toolbox --config-folder ./config.yaml
// after
toolbox --config-folder ./configs   # directory with *.yaml files
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(folder)
if err == nil && !info.IsDir() {
  return fmt.Errorf("%q is a file; use --config-file instead", folder)
}

Try / catch

paths, err := GetPathsFromConfigFolder(ctx, folder)
if err != nil {
  if strings.Contains(err.Error(), "is not a directory") {
    // caller passed a file; switch to LoadConfig with the file
  }
  return err
}

Prevention

When it happens

Trigger: Calling GetPathsFromConfigFolder with a path that points to a regular file (or symlink to a file) instead of a directory, e.g. passing --config-folder /path/to/config.yaml.

Common situations: Confusing --config-folder with --config-file and passing a YAML file path; a symlink pointing at a file instead of a directory.

Related errors


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