From 2b4e4b912600071e628a162bf8ded72043f31aee Mon Sep 17 00:00:00 2001 From: He-Pin Date: Fri, 31 Oct 2025 16:24:00 +0800 Subject: [PATCH 1/2] chore: Spring 5 compatibility Signed-off-by: He-Pin --- .../WebClientStreamableHttpTransport.java | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 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 b67d34f6b..6ce440e89 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 @@ -308,7 +308,7 @@ public Mono sendMessage(McpSchema.JSONRPCMessage message) { // The spec mentions only ACCEPTED, but the existing SDKs can return // 200 OK for notifications - if (response.statusCode().is2xxSuccessful()) { + if (is2xx(response)) { Optional contentType = response.headers().contentType(); long contentLength = response.headers().contentLength().orElse(-1); // Existing SDKs consume notifications with no response body nor @@ -392,14 +392,15 @@ 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.statusCode(), body); + logger.debug("Received content together with {} HTTP code response: {}", response.rawStatusCode(), + 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 (responseException.getStatusCode().isSameCodeAs(HttpStatus.BAD_REQUEST)) { + if (isBadRequest(responseException)) { if (!sessionRepresentation.equals(MISSING_SESSION_ID)) { return Mono.error(new McpTransportSessionNotFoundException(sessionRepresentation, toPropagate)); } @@ -419,16 +420,8 @@ private Flux eventStream(McpTransportStream= 200 && response.rawStatusCode() < 300; + } + } From 70502e7d3972fad7164c95f9b2fba0f418ca38e5 Mon Sep 17 00:00:00 2001 From: He-Pin Date: Tue, 18 Nov 2025 22:52:38 +0800 Subject: [PATCH 2/2] . Signed-off-by: He-Pin --- .../client/transport/WebClientStreamableHttpTransport.java | 4 ++++ 1 file changed, 4 insertions(+) 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 6ce440e89..6b1d6ba8a 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 @@ -603,6 +603,7 @@ public WebClientStreamableHttpTransport build() { /** * Needed for Spring 5 compatibility */ + @SuppressWarnings("deprecation") private static boolean isBadRequest(final WebClientResponseException responseException) { return responseException.getRawStatusCode() == HttpStatus.BAD_REQUEST.value(); } @@ -610,6 +611,7 @@ private static boolean isBadRequest(final WebClientResponseException responseExc /** * Needed for Spring 5 compatibility */ + @SuppressWarnings("deprecation") private static boolean isNotFound(ClientResponse response) { return response.rawStatusCode() == HttpStatus.NOT_FOUND.value(); } @@ -617,6 +619,7 @@ private static boolean isNotFound(ClientResponse response) { /** * Needed for Spring 5 compatibility */ + @SuppressWarnings("deprecation") private static boolean isNotAllowed(ClientResponse response) { return response.rawStatusCode() == HttpStatus.METHOD_NOT_ALLOWED.value(); } @@ -624,6 +627,7 @@ private static boolean isNotAllowed(ClientResponse response) { /** * Needed for Spring 5 compatibility */ + @SuppressWarnings("deprecation") private static boolean is2xx(final ClientResponse response) { return response.rawStatusCode() >= 200 && response.rawStatusCode() < 300; }