Fix UTF-8 encoding for non-ASCII tool names in HTTP client transports by rameshreddy-adutla · Pull Request #850 · modelcontextprotocol/java-sdk

@rameshreddy-adutla

Both HttpClientSseClientTransport and HttpClientStreamableHttpTransport
set Content-Type to 'application/json' without specifying the charset.
While Java's BodyPublishers.ofString() uses UTF-8 by default, the
missing charset in the header can cause the server to interpret the
request body using a different encoding (e.g., ISO-8859-1), corrupting
non-ASCII characters such as Chinese tool names.

Explicitly set Content-Type to 'application/json; charset=utf-8' in
POST requests on both client transports.

Fixes modelcontextprotocol#260

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>