Add explicit UTF-8 charset to InputStreamReader in StdioServerTransportProvider by xxxxxxjun · Pull Request #826 · modelcontextprotocol/java-sdk

@xxxxxxjun

Verifies that multi-byte UTF-8 characters (Korean, emoji, accented
Latin, Japanese) are correctly preserved through the STDIO inbound
processing pipeline.
Use natural script names (한글, 漢字) and a common accented
word (café) for UTF-8 encoding test data.

@xxxxxxjun

chemicL

The test passes regardless of whether UTF-8 is explicitly specified,
because the test environment default charset is already UTF-8.
Spawns a child JVM with -Dfile.encoding=ISO-8859-1 to simulate a
non-UTF-8 default charset environment. The test sends a JSON-RPC
message containing multi-byte characters (Korean, Chinese, accented
Latin, emoji) through StdioServerTransportProvider and verifies they
are preserved. This test fails without the explicit UTF-8 charset
fix and passes with it.

@xxxxxxjun

…tocol#295

The issue only reports encoding inconsistency in
StdioServerTransportProvider. Revert StdioClientTransport to its
original state to keep the PR scoped to the reported problem.

@xxxxxxjun xxxxxxjun changed the title Specify UTF-8 charset explicitly in STDIO transport InputStreamReader Add explicit UTF-8 charset to InputStreamReader in StdioServerTransportProvider

Feb 22, 2026

chemicL pushed a commit that referenced this pull request

Mar 2, 2026
Also add a test simulating a different locale in an isolated process.

Resolves #295

@xxxxxxjun xxxxxxjun deleted the fix/stdio-encoding-inconsistency branch

March 9, 2026 13:56

@bhsz bhsz mentioned this pull request

Mar 23, 2026