diff --git a/mcp-test/pom.xml b/mcp-test/pom.xml
index 77405bdc1..51876e84d 100644
--- a/mcp-test/pom.xml
+++ b/mcp-test/pom.xml
@@ -96,27 +96,6 @@
-
- org.springframework
- spring-webmvc
- ${springframework.version}
- test
-
-
-
- org.springframework
- spring-context
- ${springframework.version}
- test
-
-
-
- org.springframework
- spring-test
- ${springframework.version}
- test
-
-
io.projectreactor.netty
reactor-netty-http
diff --git a/mcp-test/src/test/java/io/modelcontextprotocol/client/transport/HttpClientSseClientTransportTests.java b/mcp-test/src/test/java/io/modelcontextprotocol/client/transport/HttpClientSseClientTransportTests.java
index 35b13815e..505622718 100644
--- a/mcp-test/src/test/java/io/modelcontextprotocol/client/transport/HttpClientSseClientTransportTests.java
+++ b/mcp-test/src/test/java/io/modelcontextprotocol/client/transport/HttpClientSseClientTransportTests.java
@@ -5,6 +5,7 @@
package io.modelcontextprotocol.client.transport;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.time.Duration;
@@ -30,11 +31,8 @@
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import reactor.core.publisher.Mono;
-import reactor.core.publisher.Sinks;
import reactor.test.StepVerifier;
-import org.springframework.http.codec.ServerSentEvent;
-import org.springframework.web.util.UriComponentsBuilder;
import static io.modelcontextprotocol.util.McpJsonMapperUtils.JSON_MAPPER;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
@@ -78,8 +76,6 @@ static class TestHttpClientSseClientTransport extends HttpClientSseClientTranspo
private final AtomicInteger inboundMessageCount = new AtomicInteger(0);
- private Sinks.Many> events = Sinks.many().unicast().onBackpressureBuffer();
-
public TestHttpClientSseClientTransport(final String baseUri,
SseMessageEndpointValidator sseMessageEndpointValidator) {
super(HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build(),
@@ -91,13 +87,7 @@ public int getInboundMessageCount() {
return inboundMessageCount.get();
}
- public void simulateEndpointEvent(String jsonMessage) {
- events.tryEmitNext(ServerSentEvent.builder().event("endpoint").data(jsonMessage).build());
- inboundMessageCount.incrementAndGet();
- }
-
public void simulateMessageEvent(String jsonMessage) {
- events.tryEmitNext(ServerSentEvent.builder().event("message").data(jsonMessage).build());
inboundMessageCount.incrementAndGet();
}
@@ -333,7 +323,7 @@ void testCustomizeClient() {
}
@Test
- void testRequestCustomizer() {
+ void testRequestCustomizer() throws URISyntaxException {
var mockCustomizer = mock(McpSyncHttpClientRequestCustomizer.class);
// Create a transport with the customizer
@@ -348,8 +338,7 @@ void testRequestCustomizer() {
.verifyComplete();
// Verify the customizer was called
- verify(mockCustomizer).customize(any(), eq("GET"),
- eq(UriComponentsBuilder.fromUriString(host).path("/sse").build().toUri()), isNull(), eq(context));
+ verify(mockCustomizer).customize(any(), eq("GET"), eq(new URI(host + "/sse")), isNull(), eq(context));
clearInvocations(mockCustomizer);
// Send test message
@@ -373,7 +362,7 @@ void testRequestCustomizer() {
}
@Test
- void testAsyncRequestCustomizer() {
+ void testAsyncRequestCustomizer() throws URISyntaxException {
var mockCustomizer = mock(McpAsyncHttpClientRequestCustomizer.class);
when(mockCustomizer.customize(any(), any(), any(), any(), any()))
.thenAnswer(invocation -> Mono.just(invocation.getArguments()[0]));
@@ -390,8 +379,7 @@ void testAsyncRequestCustomizer() {
.verifyComplete();
// Verify the customizer was called
- verify(mockCustomizer).customize(any(), eq("GET"),
- eq(UriComponentsBuilder.fromUriString(host).path("/sse").build().toUri()), isNull(), eq(context));
+ verify(mockCustomizer).customize(any(), eq("GET"), eq(new URI(host + "/sse")), isNull(), eq(context));
clearInvocations(mockCustomizer);
// Send test message
diff --git a/mcp-test/src/test/java/io/modelcontextprotocol/server/HttpServletStatelessIntegrationTests.java b/mcp-test/src/test/java/io/modelcontextprotocol/server/HttpServletStatelessIntegrationTests.java
index 6c6776c2b..5cb53b233 100644
--- a/mcp-test/src/test/java/io/modelcontextprotocol/server/HttpServletStatelessIntegrationTests.java
+++ b/mcp-test/src/test/java/io/modelcontextprotocol/server/HttpServletStatelessIntegrationTests.java
@@ -60,9 +60,6 @@
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
-import org.springframework.mock.web.MockHttpServletRequest;
-import org.springframework.mock.web.MockHttpServletResponse;
-import org.springframework.web.client.RestClient;
import static io.modelcontextprotocol.server.transport.HttpServletStatelessServerTransport.APPLICATION_JSON;
import static io.modelcontextprotocol.server.transport.HttpServletStatelessServerTransport.TEXT_EVENT_STREAM;
import static io.modelcontextprotocol.util.McpJsonMapperUtils.JSON_MAPPER;
@@ -140,12 +137,18 @@ void testToolCallSuccess() {
Tool.builder("tool1", EMPTY_JSON_SCHEMA).title("tool1 description").build(),
(transportContext, request) -> {
// perform a blocking call to a remote service
- String response = RestClient.create()
- .get()
- .uri("https://raw.githubusercontent.com/modelcontextprotocol/java-sdk/refs/heads/main/README.md")
- .retrieve()
- .body(String.class);
- assertThat(response).isNotBlank();
+ try {
+ HttpResponse response = HttpClient.newHttpClient()
+ .send(HttpRequest.newBuilder()
+ .uri(URI.create(
+ "https://raw.githubusercontent.com/modelcontextprotocol/java-sdk/refs/heads/main/README.md"))
+ .GET()
+ .build(), HttpResponse.BodyHandlers.ofString());
+ assertThat(response.body()).isNotBlank();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
return callResponse;
});
@@ -714,34 +717,19 @@ void testThrownMcpErrorAndJsonRpcError() throws Exception {
mcpServer.addTool(toolSpec);
- McpSchema.CallToolRequest callToolRequest = McpSchema.CallToolRequest.builder("test")
- .arguments(Map.of())
+ var request = HttpRequest.newBuilder()
+ .uri(URI.create("http://localhost:" + PORT + CUSTOM_MESSAGE_ENDPOINT))
+ .header("Content-Type", APPLICATION_JSON)
+ .header("Accept", APPLICATION_JSON + ", " + TEXT_EVENT_STREAM)
+ .header(HttpHeaders.PROTOCOL_VERSION, ProtocolVersions.MCP_2025_03_26)
+ .POST(HttpRequest.BodyPublishers.ofString("""
+ {"jsonrpc":"2.0","id":"test","method":"tools/call","params":{"name":"test","arguments":{}}}"""))
.build();
- McpSchema.JSONRPCRequest jsonrpcRequest = new McpSchema.JSONRPCRequest(McpSchema.METHOD_TOOLS_CALL, "test",
- callToolRequest);
-
- MockHttpServletRequest request = new MockHttpServletRequest("POST", CUSTOM_MESSAGE_ENDPOINT);
- MockHttpServletResponse response = new MockHttpServletResponse();
-
- byte[] content = JSON_MAPPER.writeValueAsBytes(jsonrpcRequest);
- request.setContent(content);
- request.addHeader("Content-Type", "application/json");
- request.addHeader("Content-Length", Integer.toString(content.length));
- request.addHeader("Content-Length", Integer.toString(content.length));
- request.addHeader("Accept", APPLICATION_JSON + ", " + TEXT_EVENT_STREAM);
- request.addHeader("Content-Type", APPLICATION_JSON);
- request.addHeader("Cache-Control", "no-cache");
- request.addHeader(HttpHeaders.PROTOCOL_VERSION, ProtocolVersions.MCP_2025_03_26);
- mcpStatelessServerTransport.service(request, response);
-
- McpSchema.JSONRPCResponse jsonrpcResponse = JSON_MAPPER.readValue(response.getContentAsByteArray(),
- McpSchema.JSONRPCResponse.class);
+ var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
- assertThat(jsonrpcResponse).isNotNull();
- assertThat(jsonrpcResponse.error()).isNotNull();
- assertThat(jsonrpcResponse.error().code()).isEqualTo(ErrorCodes.INTERNAL_ERROR);
- assertThat(jsonrpcResponse.error().message()).isEqualTo("testing");
+ assertThatJson(response.body()).inPath("error.code").isEqualTo(ErrorCodes.INTERNAL_ERROR);
+ assertThatJson(response.body()).inPath("error.message").isEqualTo("testing");
}
@Test
diff --git a/pom.xml b/pom.xml
index 2ad8c312f..e710cae85 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,7 +75,6 @@
2.21
2.21.1
3.1.4
- 6.2.19
3.16.0