Skip to content

Commit 5057f22

Browse files
committed
Fix mcp-spring incompatibility issue with Spring Framework 6.x and 7.0
- Replace deprecated rawStatusCode() for Spring Framework 7.0 compatibility in WebClientStreamableHttpTransport - Replace usage of rawStatusCode() and getRawStatusCode() methods with statusCode().value() to ensure compatibility with Spring Framework 7.0 where these deprecated methods have been removed.
1 parent e6045f7 commit 5057f22

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

mcp-spring/mcp-spring-webflux/src/main/java/io/modelcontextprotocol/client/transport/WebClientStreamableHttpTransport.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ private Flux<McpSchema.JSONRPCMessage> extractError(ClientResponse response, Str
397397
}
398398
catch (IOException ex) {
399399
toPropagate = new McpTransportException("Sending request failed, " + e.getMessage(), e);
400-
logger.debug("Received content together with {} HTTP code response: {}", response.rawStatusCode(),
400+
logger.debug("Received content together with {} HTTP code response: {}", response.statusCode().value(),
401401
body);
402402
}
403403

@@ -608,33 +608,29 @@ public WebClientStreamableHttpTransport build() {
608608
/**
609609
* Needed for Spring 5 compatibility
610610
*/
611-
@SuppressWarnings("deprecation")
612611
private static boolean isBadRequest(final WebClientResponseException responseException) {
613-
return responseException.getRawStatusCode() == HttpStatus.BAD_REQUEST.value();
612+
return responseException.getStatusCode().value() == HttpStatus.BAD_REQUEST.value();
614613
}
615614

616615
/**
617616
* Needed for Spring 5 compatibility
618617
*/
619-
@SuppressWarnings("deprecation")
620618
private static boolean isNotFound(ClientResponse response) {
621-
return response.rawStatusCode() == HttpStatus.NOT_FOUND.value();
619+
return response.statusCode().value() == HttpStatus.NOT_FOUND.value();
622620
}
623621

624622
/**
625623
* Needed for Spring 5 compatibility
626624
*/
627-
@SuppressWarnings("deprecation")
628625
private static boolean isNotAllowed(ClientResponse response) {
629-
return response.rawStatusCode() == HttpStatus.METHOD_NOT_ALLOWED.value();
626+
return response.statusCode().value() == HttpStatus.METHOD_NOT_ALLOWED.value();
630627
}
631628

632629
/**
633630
* Needed for Spring 5 compatibility
634631
*/
635-
@SuppressWarnings("deprecation")
636632
private static boolean is2xx(final ClientResponse response) {
637-
return response.rawStatusCode() >= 200 && response.rawStatusCode() < 300;
633+
return response.statusCode().value() >= 200 && response.statusCode().value() < 300;
638634
}
639635

640636
}

0 commit comments

Comments
 (0)