Conversation
…nterval to schema Three compliance fixes reported in #3272: 1. keepaliveInterval missing from embedded JSON schema (spec §4.1.3.5) - Add keepaliveInterval to fixSchemaBytes alongside trustedBots - Previously, schema validation rejected the field with additionalProperties:false even though StdinGatewayConfig.KeepaliveInterval already existed in Go 2. payloadSizeThreshold silently ignored in JSON stdin format (spec §4.1.3.3) - Add PayloadSizeThreshold *int field to StdinGatewayConfig - Wire it in convertStdinConfig to cfg.Gateway.PayloadSizeThreshold - Add validation: must be positive integer when present 3. payload_size_threshold not validated as positive integer in TOML path (spec §4.1.3.3) - Negative values now rejected in ParseConfig after applyDefaults - Zero is already replaced with DefaultPayloadSizeThreshold by applyDefaults Tests added for all three fixes. Fixes #3272 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses MCP Gateway spec-compliance gaps in config handling by aligning JSON stdin parsing/validation and the embedded JSON schema with supported gateway config fields, and by rejecting invalid payload threshold values in the TOML load path.
Changes:
- Extend the embedded JSON schema fix-up to allow
keepaliveIntervalingatewayconfigs. - Add
payloadSizeThresholdsupport to JSON stdin (StdinGatewayConfig) and wire it into the internalGatewayConfig. - Add validation to reject invalid
payloadSizeThreshold(JSON stdin) and negativepayload_size_threshold(TOML).
Show a summary per file
| File | Description |
|---|---|
| internal/config/validation.go | Adds JSON-stdin validation for payloadSizeThreshold >= 1. |
| internal/config/validation_schema.go | Dynamically injects keepaliveInterval into the embedded schema. |
| internal/config/validation_schema_test.go | Adds schema acceptance tests for keepaliveInterval (incl. -1). |
| internal/config/config_stdin.go | Adds PayloadSizeThreshold to stdin config and maps it into GatewayConfig. |
| internal/config/config_stdin_test.go | Adds tests for stdin wiring and validation of payloadSizeThreshold. |
| internal/config/config_core.go | Rejects negative payload_size_threshold values after defaults are applied. |
| internal/config/config_core_test.go | Adds a TOML test ensuring negative payload_size_threshold is rejected. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 7/7 changed files
- Comments generated: 2
| // validation to reject the field when additionalProperties is false. | ||
| props["keepaliveInterval"] = map[string]interface{}{ | ||
| "type": "integer", | ||
| "description": "Keepalive ping interval in seconds for HTTP MCP backends. Use -1 to disable, 0 or unset for gateway default (1500s), or a positive integer for a custom interval.", |
There was a problem hiding this comment.
The newly added schema description says “0 or unset for gateway default (1500s)”, but in the JSON stdin path a user-provided keepaliveInterval=0 will be preserved (intPtrOrDefault returns 0) and GatewayConfig.HTTPKeepaliveInterval() converts 0 to a 0s duration (effectively disabling keepalive). This makes the schema/docs misleading and creates inconsistent behavior vs TOML (where 0 is normalized to the default). Consider either (a) treating 0 as unset/default during stdin conversion or validation, or (b) updating the schema description (and any related docs) to reflect that 0 disables keepalive and only nil uses the default.
| "description": "Keepalive ping interval in seconds for HTTP MCP backends. Use -1 to disable, 0 or unset for gateway default (1500s), or a positive integer for a custom interval.", | |
| "description": "Keepalive ping interval in seconds for HTTP MCP backends. Use -1 to disable, unset for the gateway default (1500s), 0 to disable HTTP keepalive, or a positive integer for a custom interval.", |
| KeepaliveInterval *int `json:"keepaliveInterval,omitempty"` | ||
| PayloadDir string `json:"payloadDir,omitempty"` | ||
| PayloadSizeThreshold *int `json:"payloadSizeThreshold,omitempty"` | ||
| TrustedBots []string `json:"trustedBots,omitempty"` |
There was a problem hiding this comment.
This change makes payloadSizeThreshold configurable via JSON stdin, but docs/CONFIGURATION.md currently lists “Payload size threshold” under “TOML-only / CLI-only options (not available in JSON stdin)”. Please update the documentation (and any related references) so users know the field is now supported in JSON stdin and what its JSON name is (payloadSizeThreshold).
See below for a potential fix:
Port *int `json:"port,omitempty"`
APIKey string `json:"apiKey,omitempty"`
Domain string `json:"domain,omitempty"`
StartupTimeout *int `json:"startupTimeout,omitempty"`
ToolTimeout *int `json:"toolTimeout,omitempty"`
// KeepaliveInterval configures the keepalive interval in JSON stdin as `keepaliveInterval`.
KeepaliveInterval *int `json:"keepaliveInterval,omitempty"`
// PayloadDir configures the payload directory in JSON stdin as `payloadDir`.
PayloadDir string `json:"payloadDir,omitempty"`
// PayloadSizeThreshold configures the payload size threshold in JSON stdin as
// `payloadSizeThreshold`.
PayloadSizeThreshold *int `json:"payloadSizeThreshold,omitempty"`
// TrustedBots configures trusted bot identifiers in JSON stdin as `trustedBots`.
TrustedBots []string `json:"trustedBots,omitempty"`
OpenTelemetry *StdinOpenTelemetryConfig `json:"opentelemetry,omitempty"`
🤖 This PR was created by Repo Assist, an automated AI assistant.
Fixes three compliance gaps identified in #3272 (Daily Compliance Review 2026-04-06).
What
1.
keepaliveIntervalrejected by JSON schema (spec §4.1.3.5)The embedded schema (
v0.64.4) did not includekeepaliveIntervalingatewayConfig.properties, causing schema validation to reject it withadditionalProperties: false. The Go structStdinGatewayConfig.KeepaliveIntervalalready existed — only the schema was wrong.Fix: Register
keepaliveIntervalinfixSchemaBytesalongsidetrustedBots, using the same dynamic-addition pattern.2.
payloadSizeThresholdsilently ignored in JSON stdin (spec §4.1.3.3)The embedded schema correctly listed
payloadSizeThresholdingatewayConfig.properties, so validation passed — butStdinGatewayConfighad noPayloadSizeThresholdfield. Go's JSON unmarshaler silently dropped the value.Fix: Add
PayloadSizeThreshold *inttoStdinGatewayConfigand wire it inconvertStdinConfig.3. Negative
payload_size_thresholdnot rejected in TOML path (spec §4.1.3.3)applyDefaultsreplaced0with the default, but a negative value like-1passed all validation and would silently cause every payload to be stored to disk.Fix: After
applyDefaults, reject any negativePayloadSizeThresholdinParseConfig.A validation check for the JSON stdin path (in
validateGatewayConfig) also ensurespayloadSizeThresholdis positive when provided.Changes
internal/config/validation_schema.gokeepaliveIntervalinfixSchemaBytesinternal/config/config_stdin.goPayloadSizeThreshold *inttoStdinGatewayConfig; wire inconvertStdinConfiginternal/config/validation.gopayloadSizeThreshold >= 1in JSON stdin pathinternal/config/config_core.goPayloadSizeThreshold >= 0in TOML pathinternal/config/config_stdin_test.gointernal/config/config_core_test.gointernal/config/validation_schema_test.gokeepaliveIntervalis now acceptedTest Status
The changes are straightforward struct field additions, wiring, and a bounds check. All logic is covered by new unit tests that will run in CI.
CI will verify all three fixes via the new tests added to
config_stdin_test.go,config_core_test.go, andvalidation_schema_test.go.