Describe the bug
The SSE client will not raise any exception if MCP server responds with HTTP 200 and text/html content type at the time of connection:
async with sse_client(url) as (reader, writer)
The following event is logged.
{"event": "Error in sse_reader: Expected response header Content-Type to contain 'text/event-stream', got 'text/html'", "level": "error", "timestamp": "2025-05-13T13:22:19.309017Z"}
Since no exception is raised, there's no way to detect and rectify this issue in the control loop. I accidentally discovered this because I had mistakenly been running open-webui on port 8080, the same port my MCP server was supposed to run on.
To Reproduce
Steps to reproduce the behavior:
- Use an HTTP URL that returns 200 with an HTML document in the SSE client initialization
- Wrap the initialization in a try-except block, and check whether exception is raised
Expected behavior
Client should raise exception if the response is not correct.
Desktop (please complete the following information):
- OS: macOS
- Version: 15.4.1 (24E263)
- MCP Package version: 1.8.0
Describe the bug
The SSE client will not raise any exception if MCP server responds with HTTP 200 and
text/htmlcontent type at the time of connection:The following event is logged.
Since no exception is raised, there's no way to detect and rectify this issue in the control loop. I accidentally discovered this because I had mistakenly been running open-webui on port 8080, the same port my MCP server was supposed to run on.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Client should raise exception if the response is not correct.
Desktop (please complete the following information):