feat: add config validation mode - #64
Conversation
Add a `-check-config` CLI flag that loads and validates the configured local or remote config, then exits without binding the HTTP server. Useful for CI, init containers, deployment scripts, and dashboards that validate generated mcp-proxy config before restarting a live proxy. Prints `Config OK: <N> MCP server(s) configured` on success (exit 0), or an error on invalid config (non-zero exit). Documented in docs/USAGE.md.
There was a problem hiding this comment.
Code Review
This pull request introduces a -check-config flag to load and validate the configuration file without starting the HTTP server, along with updated documentation in docs/USAGE.md. Feedback on the changes points out that the current implementation only loads the JSON file but fails to validate individual MCP server configurations. It is recommended to iterate through the configured servers and validate each one using parseMCPClientConfigV2 to ensure invalid configurations are caught.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if *checkConfig { | ||
| fmt.Printf("Config OK: %d MCP server(s) configured\n", len(config.McpServers)) | ||
| return | ||
| } |
There was a problem hiding this comment.
The -check-config flag is intended to validate the configuration, but currently it only loads the JSON file and checks if mcpProxy is present. It does not validate the individual MCP server configurations (e.g., checking if a stdio transport has a command specified, or if the transport type is valid), which are validated via parseMCPClientConfigV2 during normal startup.
To ensure that invalid server configurations are caught during the config check, we should iterate over the configured servers and validate each one using parseMCPClientConfigV2.
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
}There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7052123188
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if *checkConfig { | ||
| fmt.Printf("Config OK: %d MCP server(s) configured\n", len(config.McpServers)) | ||
| return |
There was a problem hiding this comment.
Run the same per-server validation in check mode
Because this branch returns immediately after load(), -check-config skips the per-server validation that normal startup performs through startHTTPServer/newMCPClient/newMCPServer. For example, a config containing a server with transportType: "stdio" but no command will still print Config OK here, while normal startup fails in parseMCPClientConfigV2 with command is required for stdio transport, so CI or init containers can approve configs that the proxy cannot start with.
Useful? React with 👍 / 👎.
Summary
Adds a
-check-configCLI flag that loads and validates the configured local or remote config, then exits without binding the HTTP server.This is useful for CI, init containers, deployment scripts, and dashboards that want to validate generated mcp-proxy config before restarting a live proxy.
Changes
-check-configflag.docs/USAGE.md.Verification
go test ./...go run . -config config.json -check-config