googleapis/mcp-toolbox · error
unable to merge config files: %w
Error message
unable to merge config files: %w
What it means
When more than one config was loaded, mergeConfigs combines them; any error from the merge (duplicate names, multiple mcpEnabled authServices) is wrapped as 'unable to merge config files' with the underlying reason.
Source
Thrown at cmd/internal/config.go:527
buf, err := os.ReadFile(filePath)
if err != nil {
return Config{}, fmt.Errorf("unable to read config file at %q: %w", filePath, err)
}
config, err := p.ParseConfig(ctx, buf)
if err != nil {
return Config{}, fmt.Errorf("unable to parse config file at %q: %w", filePath, err)
}
configs = append(configs, config)
}
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 directoryView on GitHub (pinned to 8cc6e09de2)
Solutions
- Read the wrapped cause to find the conflict (usually duplicate names)
- Rename duplicates so each source/tool/authService/prompt/group is unique
- Deduplicate the list of config files being passed
Example fix
// before toolbox --config-file a.yaml --config-file a.yaml // after toolbox --config-file a.yaml --config-file b.yaml
Defensive patterns
Strategy: validation
Validate before calling
if hasDuplicates(filePaths) {
return fmt.Errorf("duplicate config files passed: %v", filePaths)
}
// plus pre-check for duplicate resource names as in error 22 Try / catch
cfg, err := parser.LoadAndMergeConfigs(ctx, files)
if err != nil {
if strings.Contains(err.Error(), "unable to merge config files") {
var mergeErr error
if errors.Unwrap(err) != nil { mergeErr = errors.Unwrap(err) }
// inspect mergeErr for the specific conflict
}
return err
} Prevention
- Deduplicate the config file list before merging
- Give resources unique names across all files
- Test multi-file merges in CI with the same files used in production
When it happens
Trigger: LoadAndMergeConfigs with len(configs) > 1 where mergeConfigs returns an error — typically duplicate resource names across files or conflicting MCP auth servers.
Common situations: Combining prebuilt configs with custom files that share tool/source names; passing overlapping config files twice.
Related errors
- resource conflicts detected: - %s Please ensure each sour
- multiple authServices with mcpEnabled=true detected: %s. Onl
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/217d3b18615ee687.
Report an issue: GitHub.