Skip to content

Commit 656395e

Browse files
tzolovilayaperumalg
authored andcommitted
feat: add streamable-HTTP transport support for MCP client
- Split MCP client auto-configuration into transport-specific modules to support new streamable-HTTP transport - spring-ai-autoconfigure-mcp-client-common (shared functionality) - spring-ai-autoconfigure-mcp-client-httpclient (HttpClient-based transports) - spring-ai-autoconfigure-mcp-client-webflux (WebFlux-based transports) - Update starters to use appropriate transport-specific modules - Add streamable-HTTP configuration properties (spring.ai.mcp.client.streamable-http) - Update documentation with streamable-HTTP transport examples - Update BOM to reflect new modular structure Signed-off-by: Christian Tzolov <[email protected]>
1 parent cf2c3c5 commit 656395e

File tree

53 files changed

+1381
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1381
-155
lines changed

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/pom.xml renamed to auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-common/pom.xml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
<version>1.1.0-SNAPSHOT</version>
1010
<relativePath>../../../pom.xml</relativePath>
1111
</parent>
12-
<artifactId>spring-ai-autoconfigure-mcp-client</artifactId>
12+
<artifactId>spring-ai-autoconfigure-mcp-client-common</artifactId>
1313
<packaging>jar</packaging>
14-
<name>Spring AI MCP Client Auto Configuration</name>
15-
<description>Spring AI MCP Client Auto Configuration</description>
14+
<name>Spring AI MCP Client Common Auto Configuration</name>
15+
<description>Spring AI MCP Client Common Auto Configuration</description>
1616
<url>https://github.com/spring-projects/spring-ai</url>
1717

1818
<scm>
@@ -35,11 +35,11 @@
3535
<optional>true</optional>
3636
</dependency>
3737

38-
<dependency>
38+
<!-- <dependency>
3939
<groupId>io.modelcontextprotocol.sdk</groupId>
4040
<artifactId>mcp-spring-webflux</artifactId>
4141
<optional>true</optional>
42-
</dependency>
42+
</dependency> -->
4343

4444
<dependency>
4545
<groupId>org.springframework.boot</groupId>
@@ -53,15 +53,6 @@
5353
<optional>true</optional>
5454
</dependency>
5555

56-
<!-- NOTE: Currently the webmvc doesn't implement client transport.
57-
We will add it in the future based on ResrtClient.
58-
-->
59-
<!-- <dependency>
60-
<groupId>io.modelcontextprotocol.sdk</groupId>
61-
<artifactId>mcp-spring-webmvc</artifactId>
62-
<optional>true</optional>
63-
</dependency> -->
64-
6556
<!-- Test dependencies -->
6657
<dependency>
6758
<groupId>org.springframework.ai</groupId>
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.mcp.client.autoconfigure;
17+
package org.springframework.ai.mcp.client.common.autoconfigure;
1818

1919
import java.util.ArrayList;
2020
import java.util.List;
@@ -24,9 +24,9 @@
2424
import io.modelcontextprotocol.client.McpSyncClient;
2525
import io.modelcontextprotocol.spec.McpSchema;
2626

27-
import org.springframework.ai.mcp.client.autoconfigure.configurer.McpAsyncClientConfigurer;
28-
import org.springframework.ai.mcp.client.autoconfigure.configurer.McpSyncClientConfigurer;
29-
import org.springframework.ai.mcp.client.autoconfigure.properties.McpClientCommonProperties;
27+
import org.springframework.ai.mcp.client.common.autoconfigure.configurer.McpAsyncClientConfigurer;
28+
import org.springframework.ai.mcp.client.common.autoconfigure.configurer.McpSyncClientConfigurer;
29+
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpClientCommonProperties;
3030
import org.springframework.ai.mcp.customizer.McpAsyncClientCustomizer;
3131
import org.springframework.ai.mcp.customizer.McpSyncClientCustomizer;
3232
import org.springframework.beans.factory.ObjectProvider;
@@ -98,8 +98,14 @@
9898
* @see SseHttpClientTransportAutoConfiguration
9999
* @see SseWebFluxTransportAutoConfiguration
100100
*/
101-
@AutoConfiguration(after = { StdioTransportAutoConfiguration.class, SseHttpClientTransportAutoConfiguration.class,
102-
SseWebFluxTransportAutoConfiguration.class })
101+
@AutoConfiguration(afterName = {
102+
"org.springframework.ai.mcp.client.common.autoconfigure.StdioTransportAutoConfiguration",
103+
"org.springframework.ai.mcp.client.httpclient.autoconfigure.SseHttpClientTransportAutoConfiguration",
104+
"org.springframework.ai.mcp.client.httpclient.autoconfigure.StreamableHttpHttpClientTransportAutoConfiguration",
105+
"org.springframework.ai.mcp.client.webflux.autoconfigure.SseWebFluxTransportAutoConfiguration",
106+
"org.springframework.ai.mcp.client.webflux.autoconfigure.StreamableHttpWebFluxTransportAutoConfiguration" })
107+
108+
// @AutoConfiguration
103109
@ConditionalOnClass({ McpSchema.class })
104110
@EnableConfigurationProperties(McpClientCommonProperties.class)
105111
@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.mcp.client.autoconfigure;
17+
package org.springframework.ai.mcp.client.common.autoconfigure;
1818

1919
import java.util.List;
2020

@@ -23,7 +23,7 @@
2323

2424
import org.springframework.ai.mcp.AsyncMcpToolCallbackProvider;
2525
import org.springframework.ai.mcp.SyncMcpToolCallbackProvider;
26-
import org.springframework.ai.mcp.client.autoconfigure.properties.McpClientCommonProperties;
26+
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpClientCommonProperties;
2727
import org.springframework.beans.factory.ObjectProvider;
2828
import org.springframework.boot.autoconfigure.AutoConfiguration;
2929
import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.mcp.client.autoconfigure;
17+
package org.springframework.ai.mcp.client.common.autoconfigure;
1818

1919
import io.modelcontextprotocol.spec.McpClientTransport;
2020

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.mcp.client.autoconfigure;
17+
package org.springframework.ai.mcp.client.common.autoconfigure;
1818

1919
import java.util.ArrayList;
2020
import java.util.List;
@@ -24,8 +24,8 @@
2424
import io.modelcontextprotocol.client.transport.StdioClientTransport;
2525
import io.modelcontextprotocol.spec.McpSchema;
2626

27-
import org.springframework.ai.mcp.client.autoconfigure.properties.McpClientCommonProperties;
28-
import org.springframework.ai.mcp.client.autoconfigure.properties.McpStdioClientProperties;
27+
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpClientCommonProperties;
28+
import org.springframework.ai.mcp.client.common.autoconfigure.properties.McpStdioClientProperties;
2929
import org.springframework.boot.autoconfigure.AutoConfiguration;
3030
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3131
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2025-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.ai.mcp.client.common.autoconfigure.aot;
18+
19+
import org.springframework.aot.hint.MemberCategory;
20+
import org.springframework.aot.hint.RuntimeHints;
21+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
22+
23+
import static org.springframework.ai.aot.AiRuntimeHints.findJsonAnnotatedClassesInPackage;
24+
25+
/**
26+
* @author Josh Long
27+
* @author Soby Chacko
28+
* @author Christian Tzolov
29+
*/
30+
public class McpClientAutoConfigurationRuntimeHints implements RuntimeHintsRegistrar {
31+
32+
@Override
33+
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
34+
hints.resources().registerPattern("**.json");
35+
36+
var mcs = MemberCategory.values();
37+
for (var tr : findJsonAnnotatedClassesInPackage("org.springframework.ai.mcp.client.common.autoconfigure")) {
38+
hints.reflection().registerType(tr, mcs);
39+
}
40+
}
41+
42+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.mcp.client.autoconfigure.configurer;
17+
package org.springframework.ai.mcp.client.common.autoconfigure.configurer;
1818

1919
import java.util.List;
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.mcp.client.autoconfigure.configurer;
17+
package org.springframework.ai.mcp.client.common.autoconfigure.configurer;
1818

1919
import java.util.List;
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.mcp.client.autoconfigure.properties;
17+
package org.springframework.ai.mcp.client.common.autoconfigure.properties;
1818

1919
import java.time.Duration;
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.mcp.client.autoconfigure.properties;
17+
package org.springframework.ai.mcp.client.common.autoconfigure.properties;
1818

1919
import java.util.HashMap;
2020
import java.util.Map;

0 commit comments

Comments
 (0)