Skip to content

Commit 3a4122d

Browse files
vdm24junie-agent
andcommitted
Bump MCP Java SDK to 2.0.1
The mcp-core 2.0.1 release fixes unregistered/unknown JSON-RPC methods returning HTTP 500 on stateless transports instead of a proper JSON-RPC -32601 (Method not found) response (modelcontextprotocol/java-sdk#784, fixed by modelcontextprotocol/java-sdk#800). WebFluxStatelessServerTransport and WebMvcStatelessServerTransport need no code changes of their own: they only return 500 when the handler's Mono errors, and mcp-core 2.0.1 makes the handler return a normal JSONRPCResponse instead. Fixes spring-projects#6998 Signed-off-by: Vadim Shurmialiou <[email protected]> Co-authored-by: Junie <[email protected]>
1 parent d0aca66 commit 3a4122d

5 files changed

Lines changed: 34 additions & 111 deletions

File tree

‎mcp/transport/mcp-spring-webflux/src/test/java/org/springframework/ai/mcp/WebFluxSseIT.java‎

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,17 @@
1818

1919
import java.time.Duration;
2020
import java.util.Map;
21-
import java.util.stream.Stream;
2221

2322
import io.modelcontextprotocol.AbstractMcpClientServerIntegrationTests;
2423
import io.modelcontextprotocol.client.McpClient;
25-
import io.modelcontextprotocol.client.transport.HttpClientSseClientTransport;
2624
import io.modelcontextprotocol.common.McpTransportContext;
2725
import io.modelcontextprotocol.server.McpServer;
2826
import io.modelcontextprotocol.server.McpServer.AsyncSpecification;
29-
import io.modelcontextprotocol.server.McpServer.SingleSessionSyncSpecification;
27+
import io.modelcontextprotocol.server.McpServer.SyncSpecification;
3028
import io.modelcontextprotocol.server.McpTransportContextExtractor;
3129
import org.junit.jupiter.api.AfterEach;
3230
import org.junit.jupiter.api.BeforeEach;
3331
import org.junit.jupiter.api.Timeout;
34-
import org.junit.jupiter.params.provider.Arguments;
3532
import reactor.netty.DisposableServer;
3633
import reactor.netty.http.server.HttpServer;
3734

@@ -57,26 +54,14 @@ class WebFluxSseIT extends AbstractMcpClientServerIntegrationTests {
5754
static McpTransportContextExtractor<ServerRequest> TEST_CONTEXT_EXTRACTOR = r -> McpTransportContext
5855
.create(Map.of("important", "value"));
5956

60-
static Stream<Arguments> clientsForTesting() {
61-
return Stream.of(Arguments.of("httpclient"), Arguments.of("webflux"));
62-
}
63-
6457
@Override
65-
protected void prepareClients(int port, String mcpEndpoint) {
66-
67-
clientBuilders
68-
.put("httpclient",
69-
McpClient.sync(HttpClientSseClientTransport.builder("http://127.0.0.1:" + port)
70-
.sseEndpoint(CUSTOM_SSE_ENDPOINT)
71-
.build()).initializationTimeout(Duration.ofSeconds(10)));
72-
73-
clientBuilders.put("webflux",
74-
McpClient
75-
.sync(WebFluxSseClientTransport.builder(WebClient.builder().baseUrl("http://127.0.0.1:" + port))
76-
.sseEndpoint(CUSTOM_SSE_ENDPOINT)
77-
.build())
78-
.initializationTimeout(Duration.ofSeconds(10)));
79-
58+
protected McpClient.SyncSpec getMcpClientBuilder() {
59+
return McpClient
60+
.sync(WebFluxSseClientTransport
61+
.builder(WebClient.builder().baseUrl("http://127.0.0.1:" + this.httpServer.port()))
62+
.sseEndpoint(CUSTOM_SSE_ENDPOINT)
63+
.build())
64+
.initializationTimeout(Duration.ofSeconds(10));
8065
}
8166

8267
@Override
@@ -85,7 +70,7 @@ protected AsyncSpecification<?> prepareAsyncServerBuilder() {
8570
}
8671

8772
@Override
88-
protected SingleSessionSyncSpecification prepareSyncServerBuilder() {
73+
protected SyncSpecification<?> prepareSyncServerBuilder() {
8974
return McpServer.sync(this.mcpServerTransportProvider);
9075
}
9176

@@ -101,8 +86,6 @@ public void before() {
10186
HttpHandler httpHandler = RouterFunctions.toHttpHandler(this.mcpServerTransportProvider.getRouterFunction());
10287
ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(httpHandler);
10388
this.httpServer = HttpServer.create().port(0).handle(adapter).bindNow();
104-
105-
prepareClients(this.httpServer.port(), null);
10689
}
10790

10891
@AfterEach

‎mcp/transport/mcp-spring-webflux/src/test/java/org/springframework/ai/mcp/WebFluxStreamableIT.java‎

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818

1919
import java.time.Duration;
2020
import java.util.Map;
21-
import java.util.stream.Stream;
2221

2322
import io.modelcontextprotocol.AbstractMcpClientServerIntegrationTests;
2423
import io.modelcontextprotocol.client.McpClient;
25-
import io.modelcontextprotocol.client.transport.HttpClientStreamableHttpTransport;
2624
import io.modelcontextprotocol.common.McpTransportContext;
2725
import io.modelcontextprotocol.server.McpServer;
2826
import io.modelcontextprotocol.server.McpServer.AsyncSpecification;
@@ -31,7 +29,6 @@
3129
import org.junit.jupiter.api.AfterEach;
3230
import org.junit.jupiter.api.BeforeEach;
3331
import org.junit.jupiter.api.Timeout;
34-
import org.junit.jupiter.params.provider.Arguments;
3532
import reactor.netty.DisposableServer;
3633
import reactor.netty.http.server.HttpServer;
3734

@@ -55,25 +52,14 @@ class WebFluxStreamableIT extends AbstractMcpClientServerIntegrationTests {
5552
static McpTransportContextExtractor<ServerRequest> TEST_CONTEXT_EXTRACTOR = r -> McpTransportContext
5653
.create(Map.of("important", "value"));
5754

58-
static Stream<Arguments> clientsForTesting() {
59-
return Stream.of(Arguments.of("httpclient"), Arguments.of("webflux"));
60-
}
61-
6255
@Override
63-
protected void prepareClients(int port, String mcpEndpoint) {
64-
65-
clientBuilders
66-
.put("httpclient",
67-
McpClient.sync(HttpClientStreamableHttpTransport.builder("http://127.0.0.1:" + port)
68-
.endpoint(CUSTOM_MESSAGE_ENDPOINT)
69-
.build()).initializationTimeout(Duration.ofSeconds(10)));
70-
clientBuilders.put("webflux",
71-
McpClient
72-
.sync(WebClientStreamableHttpTransport
73-
.builder(WebClient.builder().baseUrl("http://127.0.0.1:" + port))
74-
.endpoint(CUSTOM_MESSAGE_ENDPOINT)
75-
.build())
76-
.initializationTimeout(Duration.ofSeconds(10)));
56+
protected McpClient.SyncSpec getMcpClientBuilder() {
57+
return McpClient
58+
.sync(WebClientStreamableHttpTransport
59+
.builder(WebClient.builder().baseUrl("http://127.0.0.1:" + this.httpServer.port()))
60+
.endpoint(CUSTOM_MESSAGE_ENDPOINT)
61+
.build())
62+
.initializationTimeout(Duration.ofSeconds(10));
7763
}
7864

7965
@Override
@@ -98,8 +84,6 @@ public void before() {
9884
.toHttpHandler(this.mcpStreamableServerTransportProvider.getRouterFunction());
9985
ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(httpHandler);
10086
this.httpServer = HttpServer.create().port(0).handle(adapter).bindNow();
101-
102-
prepareClients(this.httpServer.port(), null);
10387
}
10488

10589
@AfterEach

‎mcp/transport/mcp-spring-webmvc/src/test/java/org/springframework/ai/mcp/server/WebMvcSseIT.java‎

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,24 @@
1818

1919
import java.time.Duration;
2020
import java.util.Map;
21-
import java.util.stream.Stream;
2221

2322
import io.modelcontextprotocol.AbstractMcpClientServerIntegrationTests;
2423
import io.modelcontextprotocol.client.McpClient;
2524
import io.modelcontextprotocol.client.transport.HttpClientSseClientTransport;
2625
import io.modelcontextprotocol.common.McpTransportContext;
2726
import io.modelcontextprotocol.server.McpServer;
2827
import io.modelcontextprotocol.server.McpServer.AsyncSpecification;
29-
import io.modelcontextprotocol.server.McpServer.SingleSessionSyncSpecification;
28+
import io.modelcontextprotocol.server.McpServer.SyncSpecification;
3029
import io.modelcontextprotocol.server.McpTransportContextExtractor;
3130
import org.apache.catalina.LifecycleException;
3231
import org.apache.catalina.LifecycleState;
3332
import org.junit.jupiter.api.AfterEach;
3433
import org.junit.jupiter.api.BeforeEach;
3534
import org.junit.jupiter.api.Timeout;
36-
import org.junit.jupiter.params.provider.Arguments;
3735

38-
import org.springframework.ai.mcp.client.webflux.transport.WebFluxSseClientTransport;
3936
import org.springframework.ai.mcp.server.webmvc.transport.WebMvcSseServerTransportProvider;
4037
import org.springframework.context.annotation.Bean;
4138
import org.springframework.context.annotation.Configuration;
42-
import org.springframework.web.reactive.function.client.WebClient;
4339
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
4440
import org.springframework.web.servlet.function.RouterFunction;
4541
import org.springframework.web.servlet.function.ServerRequest;
@@ -57,24 +53,15 @@ class WebMvcSseIT extends AbstractMcpClientServerIntegrationTests {
5753
static McpTransportContextExtractor<ServerRequest> TEST_CONTEXT_EXTRACTOR = r -> McpTransportContext
5854
.create(Map.of("important", "value"));
5955

60-
static Stream<Arguments> clientsForTesting() {
61-
return Stream.of(Arguments.of("httpclient"), Arguments.of("webflux"));
62-
}
56+
private TomcatTestUtil.TomcatServer tomcatServer;
6357

6458
@Override
65-
protected void prepareClients(int port, String mcpEndpoint) {
66-
67-
clientBuilders.put("httpclient",
68-
McpClient.sync(HttpClientSseClientTransport.builder("http://127.0.0.1:" + port).build())
69-
.initializationTimeout(Duration.ofSeconds(10)));
70-
71-
clientBuilders.put("webflux", McpClient
72-
.sync(WebFluxSseClientTransport.builder(WebClient.builder().baseUrl("http://127.0.0.1:" + port)).build())
73-
.initializationTimeout(Duration.ofSeconds(10)));
59+
protected McpClient.SyncSpec getMcpClientBuilder() {
60+
int port = this.tomcatServer.tomcat().getConnector().getLocalPort();
61+
return McpClient.sync(HttpClientSseClientTransport.builder("http://127.0.0.1:" + port).build())
62+
.initializationTimeout(Duration.ofSeconds(10));
7463
}
7564

76-
private TomcatTestUtil.TomcatServer tomcatServer;
77-
7865
@BeforeEach
7966
public void before() {
8067

@@ -88,9 +75,6 @@ public void before() {
8875
throw new RuntimeException("Failed to start Tomcat", e);
8976
}
9077

91-
int port = this.tomcatServer.tomcat().getConnector().getLocalPort();
92-
prepareClients(port, MESSAGE_ENDPOINT);
93-
9478
// Get the transport from Spring context
9579
this.mcpServerTransportProvider = this.tomcatServer.appContext()
9680
.getBean(WebMvcSseServerTransportProvider.class);
@@ -122,7 +106,7 @@ protected AsyncSpecification<?> prepareAsyncServerBuilder() {
122106
}
123107

124108
@Override
125-
protected SingleSessionSyncSpecification prepareSyncServerBuilder() {
109+
protected SyncSpecification<?> prepareSyncServerBuilder() {
126110
return McpServer.sync(this.mcpServerTransportProvider);
127111
}
128112

‎mcp/transport/mcp-spring-webmvc/src/test/java/org/springframework/ai/mcp/server/WebMvcStreamableIT.java‎

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.time.Duration;
2020
import java.util.Map;
21-
import java.util.stream.Stream;
2221

2322
import io.modelcontextprotocol.AbstractMcpClientServerIntegrationTests;
2423
import io.modelcontextprotocol.client.McpClient;
@@ -33,13 +32,10 @@
3332
import org.junit.jupiter.api.AfterEach;
3433
import org.junit.jupiter.api.BeforeEach;
3534
import org.junit.jupiter.api.Timeout;
36-
import org.junit.jupiter.params.provider.Arguments;
3735

38-
import org.springframework.ai.mcp.client.webflux.transport.WebClientStreamableHttpTransport;
3936
import org.springframework.ai.mcp.server.webmvc.transport.WebMvcStreamableServerTransportProvider;
4037
import org.springframework.context.annotation.Bean;
4138
import org.springframework.context.annotation.Configuration;
42-
import org.springframework.web.reactive.function.client.WebClient;
4339
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
4440
import org.springframework.web.servlet.function.RouterFunction;
4541
import org.springframework.web.servlet.function.ServerRequest;
@@ -57,12 +53,18 @@ class WebMvcStreamableIT extends AbstractMcpClientServerIntegrationTests {
5753
static McpTransportContextExtractor<ServerRequest> TEST_CONTEXT_EXTRACTOR = r -> McpTransportContext
5854
.create(Map.of("important", "value"));
5955

60-
static Stream<Arguments> clientsForTesting() {
61-
return Stream.of(Arguments.of("httpclient"), Arguments.of("webflux"));
62-
}
63-
6456
private TomcatTestUtil.TomcatServer tomcatServer;
6557

58+
@Override
59+
protected McpClient.SyncSpec getMcpClientBuilder() {
60+
int port = this.tomcatServer.tomcat().getConnector().getLocalPort();
61+
return McpClient
62+
.sync(HttpClientStreamableHttpTransport.builder("http://127.0.0.1:" + port)
63+
.endpoint(MESSAGE_ENDPOINT)
64+
.build())
65+
.initializationTimeout(Duration.ofSeconds(10));
66+
}
67+
6668
@BeforeEach
6769
public void before() {
6870

@@ -76,20 +78,6 @@ public void before() {
7678
throw new RuntimeException("Failed to start Tomcat", e);
7779
}
7880

79-
int port = this.tomcatServer.tomcat().getConnector().getLocalPort();
80-
81-
this.clientBuilders
82-
.put("httpclient",
83-
McpClient.sync(HttpClientStreamableHttpTransport.builder("http://127.0.0.1:" + port)
84-
.endpoint(MESSAGE_ENDPOINT)
85-
.build()).initializationTimeout(Duration.ofSeconds(10)));
86-
87-
this.clientBuilders.put("webflux",
88-
McpClient.sync(WebClientStreamableHttpTransport
89-
.builder(WebClient.builder().baseUrl("http://127.0.0.1:" + port))
90-
.endpoint(MESSAGE_ENDPOINT)
91-
.build()));
92-
9381
// Get the transport from Spring context
9482
this.mcpServerTransportProvider = this.tomcatServer.appContext()
9583
.getBean(WebMvcStreamableServerTransportProvider.class);
@@ -125,22 +113,6 @@ public void after() {
125113
}
126114
}
127115

128-
@Override
129-
protected void prepareClients(int port, String mcpEndpoint) {
130-
131-
this.clientBuilders.put("httpclient", McpClient
132-
.sync(HttpClientStreamableHttpTransport.builder("http://127.0.0.1:" + port).endpoint(mcpEndpoint).build())
133-
.initializationTimeout(Duration.ofSeconds(10)));
134-
135-
this.clientBuilders.put("webflux",
136-
McpClient
137-
.sync(WebClientStreamableHttpTransport
138-
.builder(WebClient.builder().baseUrl("http://127.0.0.1:" + port))
139-
.endpoint(mcpEndpoint)
140-
.build())
141-
.initializationTimeout(Duration.ofSeconds(10)));
142-
}
143-
144116
@Configuration
145117
@EnableWebMvc
146118
static class TestConfig {

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@
253253
<spring-boot.version>4.2.0-SNAPSHOT</spring-boot.version>
254254

255255
<!-- MCP SDK -->
256-
<mcp.sdk.version>2.0.0</mcp.sdk.version>
256+
<mcp.sdk.version>2.0.1</mcp.sdk.version>
257257

258258
<!-- AI model SDKs -->
259259
<anthropic-sdk.version>2.52.0</anthropic-sdk.version>

0 commit comments

Comments
 (0)