fix: When call the MCP SSE endpoint, the Content-Type header not passed by default#489
Conversation
|
@zhangjingcn, thanks for raising this. |
@tzolov Thank you for your reply. Our MCP server is hosted on Higress (https://higress.ai/en/), which provides features such as service management and authentication. I consulted with the Higress development team, and they explained that when Higress, acting as a gateway, receives a request containing a Content-Type header, it assumes there is a request body and attempts to read it. However, since GET requests do not actually include a body, this causes Higress to hang during processing. |
Motivation and Context
When calling the MCP SSE endpoint in the current SDK, the Content-Type: application/json header is included by default. However, the SSE endpoint is accessed via a GET request, and according to HTTP specifications, the Content-Type header should not be sent with GET requests. This has caused some MCP servers to fail validation or handle the request incorrectly. Therefore, the HttpClientSseClientTransport class has been modified so that the default request builder no longer includes the Content-Type header. The Content-Type header is now only included by default for POST requests.
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context