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

Potential encoding issue in STDIO protocol #295

Copy link
Copy link
@tomasr

Description

@tomasr
Issue body actions

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featureModerate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomersready for workThe goal is clear and work towards it can be commencedThe goal is clear and work towards it can be commenced

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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