-
Notifications
You must be signed in to change notification settings - Fork 292
fix(gateway): Correct validation for STREAMABLEHTTP transport #662
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
Conversation
When registering a gateway with transport: "STREAMABLEHTTP", the registration fails with a 502 Bad Gateway error. The underlying tool server logs show it rejects the connection attempt with a 406 Not Acceptable status. This occurs because the gateway's validation logic in `_validate_gateway_url` sends a GET request to the tool server's endpoint to check for liveness. However, the `streamable-http` protocol specification requires an initial POST request to establish a session. The tool server correctly rejects the unexpected GET request. This commit resolves the issue by bypassing the incorrect GET-based validation for the STREAMABLEHTTP transport. Instead, it proceeds directly to establishing a connection using the `streamablehttp_client`, which correctly performs the POST handshake. The existing `try...except` block in `_initialize_gateway` is sufficient to handle any genuine connection failures. Signed-off-by: Jimmy Liao <[email protected]>
|
Hi @jimmyliao |
Added some additional logging with the original code (main branch). In this case, gateway URL validation is failing because the status code is 200 and in 200 response code there is no location header. `-----------------validate_gateway_url--------------- -----------------_validate_gateway_url--------------- ERROR [mcpgateway.services.gateway_service] GatewayConnectionError in group: (GatewayConnectionError('Failed to initialize gateway at https://api.githubcopilot.com/mcp/'),) |
|
Hi @jimmyliao |
Closes #584 |
When registering a gateway with transport: "STREAMABLEHTTP", the registration fails with a 502 Bad Gateway error. The underlying tool server logs show it rejects the connection attempt with a 406 Not Acceptable status.
This occurs because the gateway's validation logic in
_validate_gateway_url
sends a GET request to the tool server's endpoint to check for liveness. However, thestreamable-http
protocol specification requires an initial POST request to establish a session. The tool server correctly rejects the unexpected GET request.This commit resolves the issue by bypassing the incorrect GET-based validation for the STREAMABLEHTTP transport. Instead, it proceeds directly to establishing a connection using the
streamablehttp_client
, which correctly performs the POST handshake. The existingtry...except
block in_initialize_gateway
is sufficient to handle any genuine connection failures.📝 Pull Request Template Selection
Thank you for contributing! To help us review your pull request effectively, please select the appropriate template:
Alternatively, after opening your pull request, you can choose the appropriate template from the "Choose a template" dropdown menu located at the top-right of the description box.
If none of the above templates fit your changes, feel free to provide a clear and concise description of your pull request below.