Skip to content

Potential encoding issue in STDIO protocol #295

Closed

Description

@tomasr

Bug description

It appears the implementation for StdioServerTransportProvider could potentially mismatch encodings between input and output.

The startOutboundProcessing method will always force the encoding to be UTF-8:

 synchronized (outputStream) {
	 outputStream.write(jsonMessage.getBytes(StandardCharsets.UTF_8));
	 outputStream.write("\n".getBytes(StandardCharsets.UTF_8));
	 outputStream.flush();
 }

However, the startInboundProcessing method doesn't appear to specify an encoding when creating the InputStreamReader object, and so it could be subject to the default charset selected by the JRE:

reader = new BufferedReader(new InputStreamReader(inputStream));

Environment
Testing with 0.10.0

Steps to reproduce

Running a STDIO-based MCP server with the JRE default charset set to something other than UTF-8.

Expected behavior
I'd expect charset/encoding handling should be consistent between input and output.

Activity

  1. chemicL commented on Feb 18, 2026

    @chemicL
    Member

    Thank you for pointing it out. I think #260 is related. I'm marking this as a good first issue and would welcome analysis and a contribution if someone is able to provide a unit test that fails and a fix.

  2. added
    bugSomething isn't working
    P3Nice to haves, rare edge cases
    ready for workThe goal is clear and work towards it can be commenced
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    and removed
    P3Nice to haves, rare edge cases
    on Feb 18, 2026
  3. added theissue type on Feb 18, 2026
  4. added 5 commits that reference this issue on Feb 21, 2026
    e02c4a4
    02999b9
    a34570a
    a4b1102
    08abf64
  5. added a commit that references this issue on Mar 2, 2026
    05f37ad
  6. added a commit that references this issue on Mar 2, 2026
    5b9c2fb
  7. removed
    ready for workThe goal is clear and work towards it can be commenced
    on Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions