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 a8a4762c2..903edf36e 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 (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 @@ -397,14 +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.statusCode(), body); + logger.debug("Received content together with {} HTTP code response: {}", getStatusCode(response), 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)); } @@ -424,16 +424,8 @@ private Flux eventStream(McpTransportStream