Skip to content

feat: add config validation mode - #64

Open
ptichalouf wants to merge 1 commit into
tbxark:masterfrom
ptichalouf:ac/add-check-config
Open

feat: add config validation mode#64
ptichalouf wants to merge 1 commit into
tbxark:masterfrom
ptichalouf:ac/add-check-config

Conversation

@ptichalouf

Copy link
Copy Markdown
Contributor

Summary

Adds a -check-config CLI 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

  • Add -check-config flag.
  • Print a concise success message with configured MCP server count.
  • Document the flag in docs/USAGE.md.

Verification

  • go test ./...
  • go run . -config config.json -check-config

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread main.go
Comment on lines +34 to +37
if *checkConfig {
fmt.Printf("Config OK: %d MCP server(s) configured\n", len(config.McpServers))
return
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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
	}

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread main.go
Comment on lines +34 to +36
if *checkConfig {
fmt.Printf("Config OK: %d MCP server(s) configured\n", len(config.McpServers))
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant