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.
Bug description
It appears the implementation for
StdioServerTransportProvidercould potentially mismatch encodings between input and output.The
startOutboundProcessingmethod will always force the encoding to be UTF-8:However, the
startInboundProcessingmethod doesn't appear to specify an encoding when creating theInputStreamReaderobject, and so it could be subject to the default charset selected by the JRE: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.