Skip to content

Commit 4867755

Browse files
committed
HttpClientStreamableHttpTransport: handle HTTP 405
- Fixes #877 Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
1 parent 7e4c179 commit 4867755

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mcp-core/src/main/java/io/modelcontextprotocol/client/transport/HttpClientStreamableHttpTransport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ private Mono<Disposable> reconnect(McpTransportStream<Disposable> stream) {
298298
"Authorization error connecting to SSE stream",
299299
responseEvent.responseInfo()));
300300
}
301+
if (statusCode == METHOD_NOT_ALLOWED) {
302+
logger.debug("The server does not support SSE streams, using request-response mode.");
303+
return Flux.empty();
304+
}
301305

302306
if (!(responseEvent instanceof ResponseSubscribers.SseResponseEvent sseResponseEvent)) {
303307
return Flux.<McpSchema.JSONRPCMessage>error(new McpTransportException(
@@ -344,10 +348,6 @@ else if (statusCode >= 200 && statusCode < 300) {
344348
return Flux.empty();
345349
}
346350
}
347-
else if (statusCode == METHOD_NOT_ALLOWED) { // NotAllowed
348-
logger.debug("The server does not support SSE streams, using request-response mode.");
349-
return Flux.empty();
350-
}
351351
else if (statusCode == NOT_FOUND) {
352352

353353
if (transportSession != null && transportSession.sessionId().isPresent()) {

0 commit comments

Comments
 (0)