HttpClientStreamableHttpTransport: handle HTTP 405

- Fixes #877

Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
This commit is contained in:
Daniel Garnier-Moiroux 2026-04-02 15:41:07 +02:00 • committed by Daniel Garnier-Moiroux
commit 8e1c5d0cd4

View file

@ -298,6 +298,10 @@ public class HttpClientStreamableHttpTransport implements McpClientTransport {
"Authorization error connecting to SSE stream",
responseEvent.responseInfo()));
}
else if (statusCode == METHOD_NOT_ALLOWED) {
logger.debug("The server does not support SSE streams, using request-response mode.");
return Flux.empty();
}
if (!(responseEvent instanceof ResponseSubscribers.SseResponseEvent sseResponseEvent)) {
return Flux.<McpSchema.JSONRPCMessage>error(new McpTransportException(
@ -344,10 +348,6 @@ public class HttpClientStreamableHttpTransport implements McpClientTransport {
return Flux.empty();
}
}
else if (statusCode == METHOD_NOT_ALLOWED) { // NotAllowed
logger.debug("The server does not support SSE streams, using request-response mode.");
return Flux.empty();
}
else if (statusCode == NOT_FOUND) {
if (transportSession != null && transportSession.sessionId().isPresent()) {