loadYaml option. This enables structured, hierarchical configuration alongside environment variables.
Overview
WhenloadYaml is enabled, the loadConfig function:
- Loads and parses YAML config files using js-yaml (v4.1.1+)
- Merges YAML config with environment variables (env vars take precedence)
- Validates the merged config against your Zod schema
Quick Start
1. Enable YAML loading
2. Create a YAML config file
3. Define your schema
Using loadConfig Directly
For programmatic configuration loading outside of plugins:Configuration Options
loadYaml
When
false (default), only environment variables and .env files are loaded. Set to true to also load YAML configuration.
configPath
Accepted File Extensions
The loader automatically tries these extensions in order:.yml.yaml- No extension (if
configPathincludes the extension)
Priority and Merging
Configuration sources are merged with this priority (highest to lowest):- Environment variables (
process.env) .env.localfile.envfile- YAML config file (when
loadYaml: true) - Schema defaults (from Zod
.default())
Environment variables always override YAML values. This allows you to commit safe defaults in YAML while overriding sensitive values via environment variables in production.
Example: Override YAML with Env Vars
database.url will be postgres://prod-server:5432/prod_db.
Error Handling
File Not Found
If the YAML file doesn’t exist, loading continues silently (no error). Schema defaults will be used.Parse Errors
If the YAML file contains invalid syntax,loadConfig throws a standard YAML parse error from js-yaml.
Validation Errors
If the merged configuration fails schema validation, aConfigValidationError is thrown:
Dependency
YAML loading depends on js-yaml version^4.1.1 or higher. This dependency is included in @frontmcp/sdk and requires no additional installation.
Complete Example
Related
- Environment Variables - .env file loading
- Schema Validation - Zod schema validation