From 12e388391944b2e05ee234fb9b7074f172737686 Mon Sep 17 00:00:00 2001 From: Christian Tzolov Date: Wed, 26 Nov 2025 12:39:38 +0100 Subject: [PATCH] Revert "WebClientStreamableHttpTransport: use Spring-5 compatible methods (#649)" This reverts commit 67f8eabb7a0ab70b43b5223768b3aaafd243c843. --- .../WebClientStreamableHttpTransport.java | 49 +++++-------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/mcp-spring/mcp-spring-webflux/src/main/java/io/modelcontextprotocol/client/transport/WebClientStreamableHttpTransport.java b/mcp-spring/mcp-spring-webflux/src/main/java/io/modelcontextprotocol/client/transport/WebClientStreamableHttpTransport.java index f0d3ad839..a8a4762c2 100644 --- a/mcp-spring/mcp-spring-webflux/src/main/java/io/modelcontextprotocol/client/transport/WebClientStreamableHttpTransport.java +++ b/mcp-spring/mcp-spring-webflux/src/main/java/io/modelcontextprotocol/client/transport/WebClientStreamableHttpTransport.java @@ -313,7 +313,7 @@ public Mono sendMessage(McpSchema.JSONRPCMessage message) { // The spec mentions only ACCEPTED, but the existing SDKs can return // 200 OK for notifications - if (is2xx(response)) { + if (response.statusCode().is2xxSuccessful()) { Optional contentType = response.headers().contentType(); long contentLength = response.headers().contentLength().orElse(-1); // Existing SDKs consume notifications with no response body nor @@ -397,15 +397,14 @@ private Flux extractError(ClientResponse response, Str } catch (IOException ex) { toPropagate = new McpTransportException("Sending request failed, " + e.getMessage(), e); - logger.debug("Received content together with {} HTTP code response: {}", response.rawStatusCode(), - body); + logger.debug("Received content together with {} HTTP code response: {}", response.statusCode(), body); } // Some implementations can return 400 when presented with a // session id that it doesn't know about, so we will // invalidate the session // https://github.com/modelcontextprotocol/typescript-sdk/issues/389 - if (isBadRequest(responseException)) { + if (responseException.getStatusCode().isSameCodeAs(HttpStatus.BAD_REQUEST)) { if (!sessionRepresentation.equals(MISSING_SESSION_ID)) { return Mono.error(new McpTransportSessionNotFoundException(sessionRepresentation, toPropagate)); } @@ -425,8 +424,16 @@ private Flux eventStream(McpTransportStream= 200 && response.rawStatusCode() < 300; - } - }