Skip to content

Commit e7a14fe

Browse files
Copilotlpcox
andcommitted
Add documentation for TOML configuration validation and error handling
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
1 parent 4b622a1 commit e7a14fe

2 files changed

Lines changed: 53 additions & 2 deletions

File tree

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,51 @@ See **[Configuration Specification](https://github.com/github/gh-aw/blob/main/do
211211
- **Passthrough**: Set value to empty string (`""`) to pass through from host
212212
- **Expansion**: Use `${VAR_NAME}` syntax for dynamic substitution (fails if undefined)
213213

214+
### Configuration Validation and Error Handling
215+
216+
MCP Gateway provides detailed error messages and validation to help catch configuration issues early:
217+
218+
#### Parse Errors with Precise Location
219+
220+
When there's a syntax error in your TOML configuration, the gateway reports the exact line and column:
221+
222+
```bash
223+
$ awmg --config config.toml
224+
Error: failed to parse TOML at line 2, column 6: expected '.' or '=', but got '3' instead
225+
```
226+
227+
This helps you quickly identify and fix syntax issues.
228+
229+
#### Unknown Key Detection (Typo Detection)
230+
231+
The gateway detects and warns about unknown configuration keys, helping catch typos and deprecated options:
232+
233+
```toml
234+
[gateway]
235+
prot = 3000 # Typo: should be 'port'
236+
startup_timout = 30 # Typo: should be 'startup_timeout'
237+
```
238+
239+
When you run the gateway with these typos, you'll see warnings in the log file:
240+
241+
```
242+
[2026-02-07T17:46:51Z] [WARN] [config] Unknown configuration key 'gateway.prot' - check for typos or deprecated options
243+
[2026-02-07T17:46:51Z] [WARN] [config] Unknown configuration key 'gateway.startup_timout' - check for typos or deprecated options
244+
```
245+
246+
The gateway will use default values for unrecognized keys, so it will still start, but the warnings help you identify and fix configuration issues.
247+
248+
#### Memory-Efficient Parsing
249+
250+
The gateway uses streaming parsing for configuration files, making it efficient even with large configuration files containing many servers.
251+
252+
#### Best Practices
253+
254+
1. **Check logs for warnings**: After starting the gateway, check the log file for any warnings about unknown keys
255+
2. **Use precise error messages**: When you see a parse error, the line and column numbers point exactly to the problem
256+
3. **Validate configuration**: Test your configuration changes by running the gateway and checking for warnings
257+
4. **Keep configuration clean**: Remove any deprecated or unused configuration options
258+
214259
## Usage
215260

216261
```

config.example.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,14 @@ args = [
139139
#
140140
# Configuration Validation:
141141
# - Required fields: command, args (for stdio servers)
142-
# - Unknown keys will generate warnings in logs
143-
# - Parse errors will show line numbers for easy debugging
142+
# - Unknown keys will generate warnings in logs (helps catch typos!)
143+
# - Parse errors show exact line and column numbers for easy debugging
144+
# - Example: "failed to parse TOML at line 2, column 6: expected '=' ..."
145+
#
146+
# Common Typos Detected:
147+
# - prot → port
148+
# - startup_timout → startup_timeout
149+
# - tool_timout → tool_timeout
144150
#
145151
# For more information, see:
146152
# - MCP Protocol: https://github.com/modelcontextprotocol

0 commit comments

Comments
 (0)