googleapis/mcp-toolbox · error

unable to parse config file at %q: %w

Error message

unable to parse config file at %q: %w

What it means

After reading a config file, LoadAndMergeConfigs calls ParseConfig. Any parse/validation failure (bad YAML syntax, unknown kind, missing required fields, failed source initialization) is wrapped with the file path so the offending file is identified.

Source

Thrown at cmd/internal/config.go:516

		return Config{}, fmt.Errorf("multiple authServices with mcpEnabled=true detected: %s. Only one MCP authorization server is currently supported", strings.Join(mcpEnabledAuthServers, ", "))
	}

	return merged, nil
}

// LoadAndMergeConfigs loads multiple YAML files and merges them
func (p *ConfigParser) LoadAndMergeConfigs(ctx context.Context, filePaths []string) (Config, error) {
	var configs []Config

	for _, filePath := range filePaths {
		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

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Validate the YAML syntax of the flagged file (yamllint or an editor linter)
  2. Check that every kind value is supported by your toolbox version
  3. Fill in required fields for the failing resource and re-run

Example fix

// before
sources:
  mypg:
    kind: postgress   # typo
// after
sources:
  mypg:
    kind: postgres
Defensive patterns

Strategy: validation

Validate before calling

var probe yaml.MapSlice
if err := yaml.Unmarshal(data, &probe); err != nil {
  return fmt.Errorf("invalid YAML: %w", err)
}

Try / catch

cfg, err := parser.LoadAndMergeConfigs(ctx, files)
if err != nil {
  if strings.Contains(err.Error(), "unable to parse config file") {
    // file path is in the message; run yamllint on that file
  }
  return err
}

Prevention

When it happens

Trigger: ParseConfig returns an error for a file's bytes: invalid YAML syntax, schema validation failure (wrong/missing fields), unknown source/tool kind, or an error initializing a source.

Common situations: Indentation errors in hand-edited YAML; using a kind name that doesn't exist (typo or old version); missing required fields like uri or kind; config written for a newer toolbox version.

Understand the failure class

Related errors


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