Skip to content

fix: handle MCP SSE text/event-stream 400 error#9

Merged
lydakis merged 2 commits intolydakis:mainfrom
bitxeno:fix-http-mcp-compat
Mar 23, 2026
Merged

fix: handle MCP SSE text/event-stream 400 error#9
lydakis merged 2 commits intolydakis:mainfrom
bitxeno:fix-http-mcp-compat

Conversation

@bitxeno
Copy link
Copy Markdown
Contributor

@bitxeno bitxeno commented Mar 22, 2026

Problem

MCP servers using modelcontextprotocol/go-sdk Streamable HTTP transport return HTTP 400 when the initial GET request doesn't include proper Accept headers:

resolving source "http://xxx.com/mcp": fetching "http://xxx.com/mcp": unexpected HTTP status 400

Error source: https://github.com/modelcontextprotocol/go-sdk/blob/ea161959d7c87bd3d4bbd63cfa8df01d3ab3b304/mcp/streamable.go#L292

The server returns:

  • Status: 400 Bad Request
  • Body: Accept must contain 'text/event-stream' for GET requests

Solution

Add detection for text/event-stream in the 400 response body to trigger direct MCP URL resolution, consistent with existing handling for 401/403/405 status codes.

Changes

  • internal/bootstrap/resolve.go - Check for text/event-stream in 400 error body
  • internal/bootstrap/resolve_helpers_test.go - Add test case for the new behavior

@bitxeno bitxeno marked this pull request as ready for review March 22, 2026 10:17
@lydakis
Copy link
Copy Markdown
Owner

lydakis commented Mar 23, 2026

Thanks, this looks like a real compatibility issue. Could you also add an end-to-end regression test in internal/bootstrap/resolve_test.go that covers this 400 Bad Request text/event-stream response path through Resolve(...)?

@bitxeno
Copy link
Copy Markdown
Contributor Author

bitxeno commented Mar 23, 2026

Thanks, this looks like a real compatibility issue. Could you also add an end-to-end regression test in internal/bootstrap/resolve_test.go that covers this 400 Bad Request text/event-stream response path through Resolve(...)?

Added

Copy link
Copy Markdown
Owner

@lydakis lydakis left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for contributing, really appreciate it!

@lydakis lydakis merged commit d22ecaa into lydakis:main Mar 23, 2026
2 checks passed
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