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 5ec272961..205957fb9 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 @@ -300,7 +300,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 @@ -384,14 +384,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)); } @@ -411,16 +412,8 @@ private Flux eventStream(McpTransportStream= 200 && response.rawStatusCode() < 300; + } + }