Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kevalmahajan
Copy link
Member

@kevalmahajan kevalmahajan commented Nov 14, 2025

πŸ› Bug-fix PR


πŸ“Œ Summary

The previous gateway validation logic incorrectly handled StreamableHTTP transport detection, causing valid MCP StreamableHTTP gateways to be incorrectly rejected.

πŸ” Reproduction Steps

  1. Start any MCP server exposing POST /mcp StreamableHTTP endpoint (e.g., fastmcp example).
  2. Add the server in the gateway.
  3. Registration fails for all streamablehttp server as validation logic fails.

🐞 Root Cause

The previous implementation incorrectly validated StreamableHTTP by:

  • Expecting a GET request instead of POST.
  • Expecting an mcp-session-id header, which is NOT required per MCP spec.
  • Enforcing Content-Type: application/json only, even though StreamableHTTP may emit text/event-stream when streaming.
  • Not sending a ping method, meaning valid servers responded with errors.
  • Using the same code path as SSE for content-type testing.

As a result, most valid StreamableHTTP servers appeared β€œinvalid”.

πŸ’‘ Fix Description

Correct validation flow that:

  • Performs a JSON-RPC ping for StreamableHTTP
  • Validates response content-type (application/json or text/event-stream)
  • Eliminates incorrect assumptions about mcp-session-id headers
  • Ensures HTTP redirects, auth failures, and protocol mismatches are handled consistently
  • Uses a single request client and unified cleanup logic

πŸ§ͺ Verification

Check Command Status
Lint suite make lint βœ…
Unit tests make test βœ…
Coverage β‰₯ 90 % make coverage
Manual regression no longer fails steps / screenshots

πŸ“ MCP Compliance (if relevant)

  • Matches current MCP spec
  • No breaking change to MCP clients

βœ… Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets/credentials committed

@kevalmahajan kevalmahajan marked this pull request as draft November 14, 2025 12:11
Signed-off-by: Keval Mahajan <[email protected]>
Signed-off-by: Keval Mahajan <[email protected]>
@kevalmahajan kevalmahajan marked this pull request as ready for review November 14, 2025 14:37
Signed-off-by: Keval Mahajan <[email protected]>
@kevalmahajan kevalmahajan marked this pull request as draft November 14, 2025 18:13
Signed-off-by: Keval Mahajan <[email protected]>
@kevalmahajan kevalmahajan marked this pull request as ready for review November 14, 2025 18:24
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.

2 participants