Skip to content

Commit 497d6f1

Browse files
committed
Align with the latest version of the class StdioServerTransportProvider(#717)
1 parent 2d265b7 commit 497d6f1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

mcp-core/src/main/java/io/modelcontextprotocol/server/transport/StdioServerTransportProvider.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.io.InputStreamReader;
1111
import java.io.OutputStream;
1212
import java.nio.charset.StandardCharsets;
13+
import java.util.List;
1314
import java.util.concurrent.Executors;
1415
import java.util.concurrent.atomic.AtomicBoolean;
1516
import java.util.function.Function;
@@ -21,6 +22,7 @@
2122
import io.modelcontextprotocol.spec.McpServerSession;
2223
import io.modelcontextprotocol.spec.McpServerTransport;
2324
import io.modelcontextprotocol.spec.McpServerTransportProvider;
25+
import io.modelcontextprotocol.spec.ProtocolVersions;
2426
import io.modelcontextprotocol.util.Assert;
2527
import io.modelcontextprotocol.json.McpJsonMapper;
2628
import org.slf4j.Logger;
@@ -80,6 +82,11 @@ public StdioServerTransportProvider(McpJsonMapper jsonMapper, InputStream inputS
8082
this.outputStream = outputStream;
8183
}
8284

85+
@Override
86+
public List<String> protocolVersions() {
87+
return List.of(ProtocolVersions.MCP_2024_11_05);
88+
}
89+
8390
@Override
8491
public void setSessionFactory(McpServerSession.Factory sessionFactory) {
8592
// Create a single session for the stdio connection
@@ -131,10 +138,10 @@ private class StdioMcpSessionTransport implements McpServerTransport {
131138
private final AtomicBoolean isStarted = new AtomicBoolean(false);
132139

133140
/** Scheduler for handling inbound messages */
134-
private final Scheduler inboundScheduler;
141+
private Scheduler inboundScheduler;
135142

136143
/** Scheduler for handling outbound messages */
137-
private final Scheduler outboundScheduler;
144+
private Scheduler outboundScheduler;
138145

139146
private final Sinks.One<Void> outboundReady = Sinks.one();
140147

@@ -205,7 +212,7 @@ private void startInboundProcessing() {
205212
if (isStarted.compareAndSet(false, true)) {
206213
this.inboundScheduler.schedule(() -> {
207214
inboundReady.tryEmitValue(null);
208-
BufferedReader reader;
215+
BufferedReader reader = null;
209216
try {
210217
reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
211218
while (!isClosing.get()) {

0 commit comments

Comments
 (0)