|
10 | 10 | import java.io.InputStreamReader; |
11 | 11 | import java.io.OutputStream; |
12 | 12 | import java.nio.charset.StandardCharsets; |
| 13 | +import java.util.List; |
13 | 14 | import java.util.concurrent.Executors; |
14 | 15 | import java.util.concurrent.atomic.AtomicBoolean; |
15 | 16 | import java.util.function.Function; |
|
21 | 22 | import io.modelcontextprotocol.spec.McpServerSession; |
22 | 23 | import io.modelcontextprotocol.spec.McpServerTransport; |
23 | 24 | import io.modelcontextprotocol.spec.McpServerTransportProvider; |
| 25 | +import io.modelcontextprotocol.spec.ProtocolVersions; |
24 | 26 | import io.modelcontextprotocol.util.Assert; |
25 | 27 | import io.modelcontextprotocol.json.McpJsonMapper; |
26 | 28 | import org.slf4j.Logger; |
@@ -80,6 +82,11 @@ public StdioServerTransportProvider(McpJsonMapper jsonMapper, InputStream inputS |
80 | 82 | this.outputStream = outputStream; |
81 | 83 | } |
82 | 84 |
|
| 85 | + @Override |
| 86 | + public List<String> protocolVersions() { |
| 87 | + return List.of(ProtocolVersions.MCP_2024_11_05); |
| 88 | + } |
| 89 | + |
83 | 90 | @Override |
84 | 91 | public void setSessionFactory(McpServerSession.Factory sessionFactory) { |
85 | 92 | // Create a single session for the stdio connection |
@@ -131,10 +138,10 @@ private class StdioMcpSessionTransport implements McpServerTransport { |
131 | 138 | private final AtomicBoolean isStarted = new AtomicBoolean(false); |
132 | 139 |
|
133 | 140 | /** Scheduler for handling inbound messages */ |
134 | | - private final Scheduler inboundScheduler; |
| 141 | + private Scheduler inboundScheduler; |
135 | 142 |
|
136 | 143 | /** Scheduler for handling outbound messages */ |
137 | | - private final Scheduler outboundScheduler; |
| 144 | + private Scheduler outboundScheduler; |
138 | 145 |
|
139 | 146 | private final Sinks.One<Void> outboundReady = Sinks.one(); |
140 | 147 |
|
@@ -205,7 +212,7 @@ private void startInboundProcessing() { |
205 | 212 | if (isStarted.compareAndSet(false, true)) { |
206 | 213 | this.inboundScheduler.schedule(() -> { |
207 | 214 | inboundReady.tryEmitValue(null); |
208 | | - BufferedReader reader; |
| 215 | + BufferedReader reader = null; |
209 | 216 | try { |
210 | 217 | reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); |
211 | 218 | while (!isClosing.get()) { |
|
0 commit comments