Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

Specify UTF-8 charset explicitly in STDIO transport InputStreamReader#826

Open
xxxxxxjun wants to merge 6 commits intomodelcontextprotocol:mainmodelcontextprotocol/java-sdk:mainfrom
xxxxxxjun:fix/stdio-encoding-inconsistencyxxxxxxjun/java-sdk:fix/stdio-encoding-inconsistencyCopy head branch name to clipboard
Open

Specify UTF-8 charset explicitly in STDIO transport InputStreamReader#826
xxxxxxjun wants to merge 6 commits intomodelcontextprotocol:mainmodelcontextprotocol/java-sdk:mainfrom
xxxxxxjun:fix/stdio-encoding-inconsistencyxxxxxxjun/java-sdk:fix/stdio-encoding-inconsistencyCopy head branch name to clipboard

Conversation

@xxxxxxjun
Copy link

@xxxxxxjun xxxxxxjun commented Feb 21, 2026

Add explicit UTF-8 charset to InputStreamReader in STDIO transports.

Resolves #295

Motivation and Context

Input streams in StdioClientTransport and StdioServerTransportProvider were missing explicit UTF-8 charset, while output streams already specify it.

How Has This Been Tested?

Existing STDIO transport tests pass locally.

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

AI tools were used for drafting the PR description.

@xxxxxxjun xxxxxxjun force-pushed the fix/stdio-encoding-inconsistency branch from a34570a to a4b1102 Compare February 21, 2026 09:18
@chemicL
Copy link
Member

chemicL commented Feb 21, 2026

As explained in #295 (comment), a valid contribution would include a test verifying that the solution is correct. Thank you.

@chemicL chemicL added the waiting for user Waiting for user feedback or more details label Feb 21, 2026
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
Copy link
Author

@chemicL Thank you for the feedback. I've added a test that verifies multi-byte UTF-8 characters are correctly preserved through the STDIO inbound processing pipeline.


@Test
@SuppressWarnings("unchecked")
void shouldHandleUtf8EncodedMessages() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

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

the test passes without the changes.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting for user Waiting for user feedback or more details

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential encoding issue in STDIO protocol

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.