Repository navigation
Harden MCP backend redirects and add protocol keepalive canary - #17172
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
The tests can pass without detecting rejected keepalive pings or redirect-handling regressions on post-connection requests, leaving both paths inadequately covered.
2 open issues
What changed in this PR
This PR makes MCP Gateway’s HTTP backend redirect policy consistent across authentication modes while keeping SDK v1.8.0 pinned.
Changes:
- Reject same-origin and cross-origin redirects across HTTP transport fallbacks.
- Add redirect regression tests and a protocol-specific keepalive canary.
- Document final backend URL requirements and expand SDK upgrade guidance.
| File | Description |
|---|---|
internal/mcp/http_connection_test.go |
Adds redirect coverage and keepalive protocol checks. |
internal/mcp/connection.go |
Applies the shared no-redirect policy to the base HTTP client. |
docs/CONFIGURATION.md |
Documents redirect rejection for all HTTP backend connections. |
AGENTS.md |
Expands upgrade checks and clarifies deferred SDK features. |
Review effort: Max (adaptive)
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Added established-session tools/list redirect cases for all five redirect statuses and both same- and cross-origin targets; the tests verify the target is never contacted. Fixed in a37e965.
| backend.AddReceivingMiddleware(func(next sdk.MethodHandler) sdk.MethodHandler { | ||
| return func(ctx context.Context, method string, req sdk.Request) (sdk.Result, error) { | ||
| if method == "ping" { | ||
| pings.Add(1) |
There was a problem hiding this comment.
Moved JSON-RPC method counting to an HTTP wrapper before SDK handling, so rejected 2026-07-28 pings are counted too. Fixed in a37e965.
|
@copilot address review feedback |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE Notes:
|

The SDK review identified inconsistent backend redirect policies and missing protocol-specific keepalive coverage. SDK v1.8.0 remains pinned; v1.9.0-pre.1 is not a stable upgrade target.
httputil.NoRedirectPolicyto the base HTTP client, aligning unauthenticated and static-header connections with OIDC across all transport fallbacks. Both same-origin and cross-origin redirects are rejected; configure final backend URLs directly.2026-07-28sessions remain usable without them.MCPGODEBUGremoval timelines, and deferStreamKeepAliveandCommandTransport.MaxLineLengthuntil a stable SDK upgrade.