Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit 59319e5

Browse files
committed
refactor: process output writing
1 parent 8a0cd4e commit 59319e5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spring-ai-mcp-core/src/main/java/org/springframework/ai/mcp/client/stdio/StdioServerTransport.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.BufferedReader;
2020
import java.io.IOException;
2121
import java.io.InputStreamReader;
22+
import java.nio.charset.StandardCharsets;
2223
import java.util.ArrayList;
2324
import java.util.HashMap;
2425
import 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) {

0 commit comments

Comments
 (0)