File tree Expand file tree Collapse file tree
spring-ai-mcp-core/src/main/java/org/springframework/ai/mcp/client/stdio Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919import java .io .BufferedReader ;
2020import java .io .IOException ;
2121import java .io .InputStreamReader ;
22+ import java .nio .charset .StandardCharsets ;
2223import java .util .ArrayList ;
2324import java .util .HashMap ;
2425import java .util .List ;
@@ -212,9 +213,10 @@ private void startOutboundProcessing() {
212213 .handle ((message , s ) -> {
213214 if (message != null ) {
214215 try {
215- this .process .outputWriter ().write (objectMapper .writeValueAsString (message ));
216- this .process .outputWriter ().newLine ();
217- this .process .outputWriter ().flush ();
216+ String jsonMessage = objectMapper .writeValueAsString (message );
217+ this .process .getOutputStream ().write (jsonMessage .getBytes (StandardCharsets .UTF_8 ));
218+ this .process .getOutputStream ().write ("\n " .getBytes (StandardCharsets .UTF_8 ));
219+ this .process .getOutputStream ().flush ();
218220 s .next (message );
219221 }
220222 catch (IOException e ) {
You can’t perform that action at this time.
0 commit comments