Repository navigation
feat: add config validation mode #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ func main() { | |
| expandEnv := flag.Bool("expand-env", true, "expand environment variables in config file") | ||
| httpHeaders := flag.String("http-headers", "", "optional HTTP headers for config URL, format: 'Key1:Value1;Key2:Value2'") | ||
| httpTimeout := flag.Int("http-timeout", 10, "HTTP timeout in seconds when fetching config from URL") | ||
| checkConfig := flag.Bool("check-config", false, "load and validate the config, then exit without starting the server") | ||
|
|
||
| version := flag.Bool("version", false, "print version and exit") | ||
| help := flag.Bool("help", false, "print help and exit") | ||
|
|
@@ -30,6 +31,10 @@ func main() { | |
| if err != nil { | ||
| log.Fatalf("Failed to load config: %v", err) | ||
| } | ||
| if *checkConfig { | ||
| fmt.Printf("Config OK: %d MCP server(s) configured\n", len(config.McpServers)) | ||
| return | ||
| } | ||
|
Comment on lines
+34
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The To ensure that invalid server configurations are caught during the config check, we should iterate over the configured servers and validate each one using if *checkConfig {
for name, server := range config.McpServers {
if _, err := parseMCPClientConfigV2(server); err != nil {
log.Fatalf("Failed to validate config for server %q: %v", name, err)
}
}
fmt.Printf("Config OK: %d MCP server(s) configured\n", len(config.McpServers))
return
} |
||
| err = startHTTPServer(config) | ||
| if err != nil { | ||
| log.Fatalf("Failed to start server: %v", err) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this branch returns immediately after
load(),-check-configskips the per-server validation that normal startup performs throughstartHTTPServer/newMCPClient/newMCPServer. For example, a config containing a server withtransportType: "stdio"but nocommandwill still printConfig OKhere, while normal startup fails inparseMCPClientConfigV2withcommand is required for stdio transport, so CI or init containers can approve configs that the proxy cannot start with.Useful? React with 👍 / 👎.